[web2py] Re: JQuery floatThead floating table header

2019-12-09 Thread Mark
Never mind, I just found the solution. The code need to be changed to "var 
$table = $('table');"


On Monday, December 9, 2019 at 1:42:34 PM UTC-5, Mark wrote:
>
> Hello,
>
> I try to use the following JQuery code in Web2py 2.18.3 or 2.4.5, but it 
> didn't work. I hope that the table header is fixed/floating, and I am not 
> sure if there is a better way to do it in web2py. The link to 
> jquery.floatThead is https://mkoryak.github.io/floatThead/. Any help 
> would be appreciated.
>
> web2py_ajax.html
> response.files.insert(0,URL('static','js/jquery.floatThead.js'))
>
> var $table = $('.web2py_table');
> $table.floatThead();
>
> Thanks!
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/4774fe65-5954-4363-9a12-ae724982b8c9%40googlegroups.com.


[web2py] JQuery floatThead floating table header

2019-12-09 Thread Mark
Hello,

I try to use the following JQuery code in Web2py 2.18.3 or 2.4.5, but it 
didn't work. I hope that the table header is fixed/floating, and I am not 
sure if there is a better way to do it in web2py. The link to 
jquery.floatThead is https://mkoryak.github.io/floatThead/. Any help would 
be appreciated.

web2py_ajax.html
response.files.insert(0,URL('static','js/jquery.floatThead.js'))

var $table = $('.web2py_table');
$table.floatThead();

Thanks!

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/808da2e4-b554-4033-8048-6e826ba48ebd%40googlegroups.com.


[web2py] Re: Something strange in my query

2019-12-09 Thread Val K
As you can see, this is a Set, not just an attribute. When you select from a 
table that has FK, Pydal forms Sets for related tables, Set is the type that db 
(...) returns

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/42de63e2-02c2-48d8-b516-5b3cc29bdd9e%40googlegroups.com.


[web2py] Re: Something strange in my query

2019-12-09 Thread Константин Комков
I understood, that I select only one table and need take row.NAME without 
tablename. But it's intresting what is a_students attribute?

понедельник, 9 декабря 2019 г., 13:30:00 UTC+3 пользователь Константин 
Комков написал:
>
> My query return attribute 'a_students' for row, but in select I wrote '
> db.a_groups.NAME'. Why?
> Web2py 2.18.5-stable+timestamp.2019.04.08.04.22.03
> (Running on Rocket 1.2.6, Python 3.7.3)
>
> tables.py
>
> db.define_table(
>  'a_groups',
>  Field('ACADEMIC_YEAR', 'integer'),
>  Field('NAME', length=25),
>  Field('STATUS', 'integer'),
>  Field('INACTIVE', 'integer', rname='"INACTIVE"'),
>  Field('FO', 'integer'),
>  Field('WLP', 'integer'),
>  Field('FAC', 'reference t_fac'),
>  migrate=False
> )
>
> db.define_table(
>  'a_students',
>  Field('GROUP_ID', 'reference a_groups'),
>  migrate=False
> )
>
> db.define_table(
>  'tt_main',
>  Field('GROUP_ID', 'reference a_groups'),
>  Field('MODULE', 'integer'),
>  migrate=False
> )
>
> default.py
>
> groups = db((db.a_groups.FO == 1) & (db.a_groups.FAC == faculty) & 
> (db.a_groups.STATUS == 2) &
>  (db.a_groups.INACTIVE == 0)).select(db.a_groups.id, db.a_groups.NAME)
>
> for row in groups:
>  ...
>
> then I have error becouse row don't have 'a_groups'. Why I have 
> 'a_students' attribute?
>  = 1754)>, 'NAME': 'Д-А401'}>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/857717bc-b7a9-434d-b36f-c0114a33c8e6%40googlegroups.com.


[web2py] Something strange in my query

2019-12-09 Thread Константин Комков
My query return attribute 'a_students' for row, but in select I wrote 
'db.a_groups.NAME'. Why?

tables.py

db.define_table(
 'a_groups',
 Field('ACADEMIC_YEAR', 'integer'),
 Field('NAME', length=25),
 Field('STATUS', 'integer'),
 Field('INACTIVE', 'integer', rname='"INACTIVE"'),
 Field('FO', 'integer'),
 Field('WLP', 'integer'),
 Field('FAC', 'reference t_fac'),
 migrate=False
)

db.define_table(
 'a_students',
 Field('GROUP_ID', 'reference a_groups'),
 migrate=False
)

db.define_table(
 'tt_main',
 Field('GROUP_ID', 'reference a_groups'),
 Field('MODULE', 'integer'),
 migrate=False
)

default.py

groups = db((db.a_groups.FO == 1) & (db.a_groups.FAC == faculty) & 
(db.a_groups.STATUS == 2) &
 (db.a_groups.INACTIVE == 0)).select(db.a_groups.id, db.a_groups.NAME)

for row in groups:
 ...

then I have error becouse row don't have 'a_groups'. Why I have 
'a_students' attribute?
, 'NAME': 'Д-А401'}>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/737654b9-6bc0-4737-9ee5-dd216d66e54b%40googlegroups.com.


[web2py] Smartgrid with multiple references between tables - Undocumented - Solved

2019-12-09 Thread Paul Ellis
When using Smartgrid and there are multiple links between two tables. For 
example a user_id might appear multiple times in db.offer because of 
created_by, updated_by, belongs_to fields.

db.define_table(
'offer',
Field('offer_number', unique=True, label = T('Offer Number')),
Field('user_id','reference auth_user', label = T('Belongs to'), 
ondelete = 'SET NULL'),   # <- HERE
Field('customer_id','reference customer', requires=IS_NOT_EMPTY(), 
label = T('Customer Name')),
Field('reseller_id','reference reseller', requires=IS_NOT_EMPTY(), 
label = T('Business Name')),
Field('created_on', 'datetime', default=request.now, writable=False, 
label=T('Created On')),
Field('created_by', 'reference auth_user', label=T('Created By')),  
  # <- HERE
Field('updated_on', 'datetime', update=request.now, writable=False, 
label=T('Updated On')),
Field('updated_by', 'reference auth_user', writable=False),
   # <- HERE
format = '%(offer_number)s',
singular = T('Offer'),
plural = T('Offers'),
)


When viewing *db.auth_user* Smartgrid makes a button for each relationship 
i.e Customers(Belongs To), Customers(Created By), Customers(Updated By). 
This can clutter the grid a bit.

This is not in the book but it is possible for the *linked_tables *argument, 
rather than a List, to be a Dict of:
{'tablename' : [Fields]}

an empty list allows all references to be used. This is handy for tables 
where there is already only one reference. The Table still needs to be 
included in the dict. Otherwise Smartgrid will exclude it entirely.

linked_tables = {
'reseller' : [
db.auth_user.reseller_id,
db.customer.reseller_id,
db.offer.reseller_id
],
'auth_user' : [
db.customer.created_by,
db.offer.user_id,
db.auth_membership.user_id,
],
'auth_membership' : [],
'customer' : [
db.offer.customer_id,
],
'offer' : [],
},

Source: Web2Py Version 2.18.5 gluon/sqlhtml.py Lines [3316 : 3353]

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/f9afd091-3a6c-4259-a1d0-39e61bab30ef%40googlegroups.com.