开发者

jqGrid v4.0 Pager not working when using local datatype

开发者 https://www.devze.com 2023-03-04 00:12 出处:网络
Im using jqGrid v4 to display some local data.Ive tried to follow the simple example @ http://www.ok-soft-gmbh.com/jqGrid/SimpleLocalGrid.htm.My results are that the pager elements are correct but the

Im using jqGrid v4 to display some local data. Ive tried to follow the simple example @ http://www.ok-soft-gmbh.com/jqGrid/SimpleLocalGrid.htm. My results are that the pager elements are correct but they are disabled. I've attached my code if anyone can help point out where I may be going wrong. Any help appreciated. Thanks

  var myData = [
      {   id:'1',   name:'a', dob:'2000-08-26',address:'here',telNo:'2587456'},
      {   id:'2',   name:'b', dob:'2000-08-26',address:'here',telNo:'2587456'},
      {   id:'3',   name:'c', dob:'2000-08-26',address:'here',telNo:'2587456'},
      {   id:'4',   name:'d', dob:'2000-08-26',address:'here',telNo:'2587456'},
      {   id:'5',   name:'e', dob:'2000-08-26',address:'here',telNo:'2587456'},
      {   id:'6',   name:'f', dob:'2000-08-26',address:'here',telNo:'2587456'},
      {   id:'7',   name:'g', dob:'2000-08-26',address:'here',telN开发者_如何学Co:'2587456'},
      {   id:'8',   name:'h', dob:'2000-08-26',address:'here',telNo:'2587456'},
      {   id:'9',   name:'i', dob:'2000-08-26',address:'here',telNo:'2587456'},
      {   id:'10',  name:'j', dob:'2000-08-26',address:'here',telNo:'2587456'},        
      {   id:'11',  name:'k', dob:'2000-08-26',address:'here',telNo:'2587456'},
      {   id:'12',  name:'l', dob:'2000-08-26',address:'here',telNo:'2587456'},
      {   id:'13',  name:'m', dob:'2000-08-26',address:'here',telNo:'2587456'},
      {   id:'14',  name:'n', dob:'2000-08-26',address:'here',telNo:'2587456'}                     
  ];
  $("#resultGrid").jqGrid({       
datatype: "local",
    data: myData,   
autowidth:true,
colNames:['ID','Name', 'DOB', 'Address','Telephone Number'],      
colModel:[
    {name:'id',index:'id', sorttype:"text"},
    {name:'name',index:'name',  sorttype:"text"},
    {name:'dob',index:'dob', sorttype:"date", formatter:"date"},
    {name:'address',index:'address', sorttype:"text"},
    {name:'telNo',index:'telNo', align:"right",sortable:false}              
],
    rowNum:10,
            rowList:[5,10,20],
            pager: '#pager',
            gridview:true,
            rownumbers:true,                
            viewrecords: true,
            sortorder: 'desc',
            caption:'Search Results',
            height: '100%'});


Sorry, but I can't reproduce your problem. How you can see here the pager (go to the next page or to the last page) is not deacticated. You should compare exactly your code with my demo to find where is the problem.


Just make sure in your server.php, when you query, at the end you set the limits and sorting:

ORDER BY $sidx $sord LIMIT $start , $limit

The first one, makes your table sortable(ORDER BY), and the second one, using limits eq 0-5, 5-10, makes your grid move within set of records!

0

精彩评论

暂无评论...
验证码 换一张
取 消