Hi,
Just to make sure we speak same language, below is code snippet that causes
me problems described in my previous post. Please note search_widget=*None.
*I use my custom search form, instead of the grid's default, but that's
just a different html, which should not mess with the matters..
Also note, that my query is mostly based on the time, so selecting a few
days worth of records work just fine, however few months, a year, etc -
slow things down to the maximum...
Finally, I'm not quite sure if understood your statement correctly ("just
pass to grid a query"). I hope you can find out more from my code below.
Thanks
@auth.requires_login(otherwise=URL
<https://mimas.teliqo.com/examples/global/vars/URL>(r=request
<https://mimas.teliqo.com/examples/global/vars/request>,f='user',args=['login']))
def index():
## Hide / Show fields
db_2.cdr.clid.readable=True
db_2.cdr.dcontext.readable=False
db_2.cdr.channel.readable=False
db_2.cdr.dstchannel.readable=True
db_2.cdr.lastapp.readable=False
db_2.cdr.lastdata.readable=False
db_2.cdr.duration.readable=False
db_2.cdr.amaflags.readable=False
db_2.cdr.accountcode.readable=False
db_2.cdr.uniqueid.readable=True
db_2.cdr.userfield.readable=False
db_2.cdr.disposition.readable=True
## Filtering rules
generic_query = (db_2.cdr.lastapp != 'BackGround')
generic_query &= (db_2.cdr.lastapp != 'VoiceMail')
generic_query &= (db_2.cdr.lastapp != 'VoiceMailMain')
generic_query &= (db_2.cdr.lastapp != 'Hangup')
generic_query &= (db_2.cdr.lastapp != 'Playback')
generic_query &= (db_2.cdr.lastapp != 'Wait')
# Initialise GET values
request
<https://mimas.teliqo.com/examples/global/vars/request>.vars.date_from =
date_from
<...> More code <...>
# Update final query with user input
query = generic_query
## When start date
if date_from:
query &= (db_2.cdr.calldate > date_from)
if date_from and (not date_to):
<...> More code <...>
## Fields to be displayed
fields = (
db_2.cdr.calldate,
db_2.cdr.dstchannel,
db_2.cdr.clid,
db_2.cdr.src,
db_2.cdr.dst,
db_2.cdr.billsec,
db_2.cdr.disposition,
db_2.cdr.userfield,
db_2.cdr.lastapp,
)
## Define table headers as tuples/dictionaries
headers = {
'cdr.calldate': 'Date / Time',
'cdr.dstchannel': 'Extension',
'cdr.clid': 'Campaign / User',
'cdr.src': 'Source',
'cdr.dst': 'Destination',
'cdr.billsec': 'Duration',
'cdr.disposition': 'Disposition',
}
## Exports
from gluon.sqlhtml import ExporterCSV, ExporterTSV
exportclasses = {
'html': False,
'csv': (ExporterCSV, 'CSV'),
'csv_with_hidden_cols': False,
'tsv_with_hidden_cols': False,
'tsv': (ExporterTSV, 'TSV'),
'json': False,
}
## Sort by Date / Time DESC
sort_order=[~db_2.cdr.calldate]
## Grid object
form = SQLFORM <https://mimas.teliqo.com/examples/global/vars/SQLFORM>.grid(
query=query,
fields=fields,
headers=headers,
orderby=sort_order,
create=False,
deletable=False,
editable=False,
details=False,
maxtextlength=64,
paginate=50,
exportclasses=exportclasses,
search_widget=None,
)
return dict(form=form)
2014 m. spalis 3 d., penktadienis 14:00:24 UTC+1, Niphlod rašė:
>
> if your backend needs tons of times to extract 50 records (no matter what
> the page is) there's a problem. Grid has not. If ou want to show your users
> a set of records, just pass to grid a query instead of the entire table.
>
--
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].
For more options, visit https://groups.google.com/d/optout.