On Wednesday, December 18, 2013 10:04:56 AM UTC+11, Michael Pearce wrote:
>
> Hi,
>
> I'm building at Turbogears application which includes a tw2 jqGridWidget.
>
> Here is my code:
>
> class GridWidget(tw2.jqplugins.jqgrid.jqGridWidget):
>
> def prepare(self):
>
> super(GridWidget, self).prepare()
>
>
> id = 'grid_widget'
>
> options = {
>
> 'pager': 'module-0-demo_pager',
>
> 'caption': 'Registered Vehicles',
>
> 'url': '/vehicle/fetch/%d' % (int(random())),
>
> 'datatype': 'json',
>
> 'colNames': ['Rego No', 'Permit No', 'Size', 'QF Vehicle', 'Staff
> Name'],
>
> 'colModel': [
>
> {'name':'rego', 'width':50, 'align':'center', 'sortable':True,
> },
>
> {'name':'permitno', 'width':50, 'align':'center',
> 'sortable':True, },
>
> {'name':'size', 'width':50, 'align':'center', 'sortable':True,
> },
>
> {'name':'qfvehicle', 'width':50, 'align':'center',
> 'sortable':True, },
>
> {'name':'staff', 'width':80, 'align':'left', 'sortable':True,
> }, ],
>
> 'rowNum':20,
>
> 'rowList':[],
>
> 'viewrecords':True,
>
> 'imgpath':'scripts/jqGrid/themes/green/images',
>
> 'width':700,
>
> 'height':'auto',
>
> }
>
> * prmFilter = {'stringResult': True, 'searchOnEnter': False}*
>
> pager_options = {"search":True, "refresh":True, "add":False,
> "edit":False, "del":False}
>
> * prmSearch = {*
>
> * "sopt": ["cn", "bw"],*
>
> * "caption": "Search...",*
>
> * "multipleSearch": True,*
>
> }
>
> Every thing is working great except the prmFilter and the prmSearch
> features. The toolbar displays the prmFilter textboxes above each column
> and when I enter text the data reloads, however the entire data set is
> displayed and not filtered (same issue with prmSearch).
>
> I created another version using the SQLAjqGridWidget class and the
> prmFilter and prmSearch functions work fine, however no such luck with
> jqGridWidget (which I need due to better customization).
>
> Any assistance would be greatly appreciated.
>
> Thanks,
> Michael
>
>
Thanks Craig, appreciate the assistance.
Here is my fetch method which I forgot to post earlier:
@expose('json')
def fetch(self, rand, page=1, rows=20, sord=u'desc', sidx=None,
_search='false',
searchOper=u'', searchField=u'A', searchString=u'', **kw):
qry = DBSession.query(Vehicle)
result_count = qry.count()
rows = int(rows)
offset = (int(page)-1) * rows
if not sidx:
column = getattr(Vehicle, 'rego')
else:
column = getattr(Vehicle, sidx)
qry = qry.order_by(getattr(column,
sord)()).offset(offset).limit(rows).all()
records = [{'id': rw.vehicleid,
'cell': [ rw.rego_link, rw.permitno, rw.size,
rw.display_qfvehicle, rw.staff_name_link]} for rw in qry]
total = int(math.ceil(result_count / float(rows)))
return dict(page=int(page), total=total, records=result_count,
rows=records)
Regards,
Michael
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/groups/opt_out.