jQWidgets Forums

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 10 years, 10 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Sort by column on binding complete #56191

    boardofpowder
    Participant

    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!

    Sort by column on binding complete #56192

    boardofpowder
    Participant

    The link didn’t come through. Here it is again: Forked Fiddle

    Sort by column on binding complete #56193

    boardofpowder
    Participant

    Gees, it’s too early in the morning for this stuff. That was the wrong link. Use this one: Forked Fiddle

    Sort by column on binding complete #56227

    Dimitar
    Participant

    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,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.