1

Possible Duplicate:
jqgrid client side sorting with server side paging - data disappears

I have a jqGrid and trying to enable client side sorting w/ server side paging. Client side sorting will work if loadonce:true but paging will not work. If loadonce:false and I try to sort, the data disappears from the grid. Any ideas what I am missing?

  jQuery("#grid").jqGrid({
            url: getUrl(), // url w/ querystring params
            datatype: 'json',
            mtype: "GET",
            colNames: ['Name', 'Title', 'Office'],
            colModel:
            [
                { name: 'Employee.EmployeeName', index: 'Employee.EmployeeName', sortable: true, sorttype: 'text' },
                { name: 'Employee.EmployeeTitle', index: 'Employee.EmployeeTitle', sortable: true, sorttype: 'text'},
                { name: 'Employee.EmployeeOffice', index: 'Employee.EmployeeOffice', sortable: true, sorttype: 'text' }
            ],
            width: 600,
            height: 'auto',
            scrollOffset: 0,
            rowNum: 5,
            pager: jQuery("#pager"),
            rowList: [10, 25, 50],
            sortname: 'Employee.EmployeeName',
            sortorder: "asc",
            loadtext: "Loading....",
            emptyrecords: "No records to view",
            //loadonce: true, // client side sorting works but paging doesn't work
            sortable: true, 
            viewrecords: true,                                
            jsonReader: {
                repeatitems: false
            },
            loadComplete: function () {
                jQuery("#grid").jqGrid('setGridParam', { datatype: 'local' });
                jQuery("#grid").trigger("reloadGrid");
            },
            onPaging: function () {
                jQuery("#grid").jqGrid('setGridParam', { datatype: 'json' });                
            }
        });
Community
  • 1
  • 1
dm80
  • 1,228
  • 5
  • 20
  • 38

2 Answers2

0

In my experience, if you do anything server side in JQGrid using JQGrid events, you have to recreate the data on the server and rebind it to JQGrid control. The means you will have to capture the sorting information and account for that as well. The Trirand forums ( http://www.trirand.net/forum/ ) are monitored by the authors of JQGrid. You may get better help there.

0

Client side sorting will work if loadonce:true but also paging will work fine .

$(document).ready(function() {
   $("#user-list").jqGrid({
      datatype: "local", 
      height: "auto",
      autowidth: true,
      ignoreCase: true,
      colNames: ['Emp Id', 'First Name', 'Last Name'],
      colModel: [ 
                  {name:'emp_id', index:'emp_id', width:55, sorttype:"int"}, 
                  {name:'first_name',index:'first_name', width:160, sorttype:"text"}, 
                  {name:'last_name',index:'last_name', width:160, sorttype:"text"},
                ],
      pager: '#user-list-pager',
      rowNum:10,
      rowList:[10,25,50,100],
      sortname: 'first_name',
      sortorder: 'asc',
      viewrecords: true,
      caption: 'Users',
      data:<%= raw @users_jqgrid_data.to_json %>
   });
   jQuery("#user-list").jqGrid('navGrid','#user-list-pager',{del:false,add:false,edit:false},{},{},{},{multipleSearch:true}); 

} );  

I just tried a smallcode an paging and sorting works fine here.hope it helps

Thanx

Bijendra
  • 9,467
  • 8
  • 39
  • 66