jQuery UI Widgets › Forums › Grid › Sort by column on binding complete
This topic contains 3 replies, has 2 voices, and was last updated by Dimitar 11 years, 7 months ago.
-
Author
-
Hi guys,
I’m trying to presort a column in the grid when it’s rendered. I’ve written it like this:
$('#jqxgrid').on('bindingcomplete', function (event) { $("#jqxgrid").jqxGrid({'sortby', 'lastname', 'asc'}); }); var adapter = new $.jqx.dataAdapter(source); $("#jqxgrid").jqxGrid({ width: 500, theme: 'energyblue', source: adapter, sortable: true, selectionmode: 'singlecell', columns: [{ text: 'First Name', datafield: 'firstname', columngroup: 'Name', width: 90 }, { text: 'Last Name', columngroup: 'Name', datafield: 'lastname', width: 90 }, { text: 'Product', datafield: 'productname', width: 170 }, { text: 'Order Date', datafield: 'date', width: 160, cellsformat: 'dd-MMMM-yyyy' }, { text: 'Quantity', datafield: 'quantity', width: 80, cellsalign: 'right' }, { text: 'Unit Price', datafield: 'price', cellsalign: 'right', cellsformat: 'c2' }] });When I run the fiddle: , I don’t get any result
You probably recognize the code because I forked your bindingcomplete fiddle and changed the action to sortby instead of alert. I tried adding your public jqxgrid.sort.js (although I suspect that jqx-all.js has that already), but there was no change in the behaviour.
Can you have a peek and let me know if there’s something obvious wrong with how I’m trying to do this? Thanks!
The link didn’t come through. Here it is again: Forked Fiddle
Gees, it’s too early in the morning for this stuff. That was the wrong link. Use this one: Forked Fiddle
Hello boardofpowder,
This is not a correct way to call a method:
$("#jqxgrid").jqxGrid({'sortby', 'lastname', 'asc'});You need to remove the curly brackets. Here is the correct way:
$("#jqxgrid").jqxGrid('sortby', 'lastname', 'asc');Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.