Hi!
some working solution
1 build a sqlite-table in memory, as required
2 insert data in the table
3 show table in smartgird
def pro_report1():
tbl = 'proverka'
l = [e for e in db[tbl].fields if e in f_short_proverka ]
memf = [ Field('oid', 'integer', label='П id', default= 0) ] + \
[ Field(db[tbl][e].name, db[tbl][e].type, label =
db[tbl][e].label,
length= db[tbl][e].length, represent= db[tbl][e].represent )
for e in l ]
dbmem = DAL('sqlite:memory')
dbmem.define_table('mem_table',*memf)
records = db(db[tbl].id>0).select().as_list()
for r in records:
r['oid'] = r['id']
dbmem.mem_table.insert(**dbmem.mem_table._filter_fields(r))
flds= [ db[tbl][e] for e in f_short_proverka ]
rows=db(db[tbl].id>0 ).select( *flds )
exportclasses=dict(
csv_with_hidden_cols=False,
csv=False,
xml=False,
json=False,
tsv_with_hidden_cols=False,
tsv= False,
)
dbmem.mem_table.id.readable = False
grid = SQLFORM.grid(dbmem.mem_table, create=False, editable=False,
exportclasses= exportclasses,
deletable=False, buttons_placement = 'left',
showbuttontext=False)
return dict(rows=rows, l=l, records=records, grid=grid)
четверг, 18 июня 2020 г., 18:38:39 UTC+3 пользователь rāma написал:
>
> Hi all,
>
> How to sort a smartgrid with your own custom sorted id list?
>
> Say I have a id list after executing the query and I have a sorting
> functions that returns a sorted id list, how would I make smartgrid to
> commit to the ordering instead of sorting by ids by default?
>
> Thanks,
> rama
>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/63853b58-756c-4623-be23-1fd0872a08f3o%40googlegroups.com.