开发者

On 0 row in jqgrid how can we replace Page 1 of NaN to something else?

if the jqgrid has no rows at some time, it shows Page 1 of NaN what is Nan here? can't we change it to something more appropriate like Page 0 of 0 or something better?

On 0 row in jqgrid how can we replace Page 1 of NaN to something else?

my jqgrid code

var grid = jQuery("#list1");


                grid.jqGrid({

                  datastr : xml,
                  datatype: 'xmlstring',
                  colNames:['cfgId','Name', 'Host', 'Description','Product', 'Type', 'Last Updated Time','Last Updated By','',''],
                  colModel:[
                      {name:'cfgId',index:'cfgId', width:90, align:"left", hidden:true},
                      {name:'cfgName',index:'cfgName', width:90, align:"left", formatter: 'showlink', formatoptions:
                                                                                {
                                                                                    baseLinkUrl:'javascript:',
                                                                                    showAction: "goToViewAllPage('",
                                                                                    addParam: "');"

                                                                                }},
                      {name:'hostname',index:'hostname', width:90, align:"left"},
                      {name:'cfgDesc',index:'cfgDesc', width:90, align:"left"},
                      {name:'productId',index:'productId', width:60, align:"left"},
                      {name:'cfgType',index:'cfgType', width:60, align:"left"},
                      {name:'updateDate',index:'updateDate',sorttype:'Date', width:120, align:"left"},
                      {name:'emailAddress',index:'emailAddress', width:120, align:"left"},
                      {name:'absolutePath',index:'absolutePath', width:90, align:"left", hidden:true},
                      {name:'fileName',index:'fileName', width:90, align:"left", hidden:true},
                  ],
                  pager : '#gridpager',
                  rowNum:10,
                  rowList:[10,50,100],
                  scrollOffset:0,
                  height: 'auto',
                  emptyrecords: 'No configurations loaded',
                  autowidth:true,
                  viewrecords: true,
                  gridview: true,
                  multiselect: true,
                  xmlReader: {
                      root : "list",
                      row: "Response",
                      userdata: "userdata",
                      repeatitems: false
                  },
                  loadComplete: function () {
                        var count = grid.getGridParam();
                        var ts = grid[0];
                        if (ts.p.reccount === 0) {
                            grid.hide();
                            emptyMsgDiv.show();
                        } else {
                            grid.show();
                            emptyMsgDiv.hide();
                        }
                    },
                  onSelectRow: function(id,status){
                      var rowData = jQuery(this).getRowData(id); 
                      configid = rowData['cfgId'];
                      configname=rowData['cfgName'];
                      configdesc=rowData['cfgDesc'];
                      configenv=rowData['cfgType'];
                      absolutepath=rowData['absolutePath'];

                      /*filename=rowData['fileName'];
                      updatedate=rowData['updateDate'];
                      absolutepath=rowData['absolutePath'];*/
                      updateproductid=rowData['productId'];


                      $('#cfgid').removeAttr('disabled');
                      document.getElementById("cfgid").value=configid;
                      document.getElementById("cfgname").value=configname;
                      document.getElementById("cfgdesc").value=configdesc;

                      var element = document.getElementById('cfgenv');
                      if(configenv=="Production")
                          element.value = "Production";
                      else if(configenv=="Development")
                          element.value="Development";
                      else
                          element.value="Test/QA";
                      rowChecked=1;
                      currentrow=id;
                      }


                });
                grid.jqGrid('navGrid','#gridpager',{edit:false,add:false,del:false});
                jQuery("#m1").click( function() {
                    var s;
                    s = grid.jqGrid('getGridParam','selarrrow');
                    alert(s);
                });开发者_如何学C
                var myGrid = $("#list1");
                $("#cb_"+myGrid[0].id).hide();
                // place div with empty message insde of bdiv
                emptyMsgDiv.insertAfter(grid.parent());

         }

My Xml

<Response>
<isSuccess>true</isSuccess>
<operation>viewall</operation>
<message>No configurations were found for this project</message>
</Response>


It's the same problem which was described here, but with XML data.

In the line the variable rn will be declared, but it will be not assigned it any value. The first assignment of the value rn = parseInt(ts.p.rowNum,10); will be here inside of if(gxml && gl) which is false in your case. So the statement

ts.p.lastpage = Math.ceil(gl/ rn);

produce NaN value.

To fix the bug you can modify the line 1086 of the jquery.jqGrid.src.js of the jqGrid 4.1.2 from

var gl = gxml.length, j=0, grpdata={}, rn;

to

var gl = gxml.length, j=0, grpdata={}, rn = parseInt(ts.p.rowNum,10);

The line 1088 which contains the same assignment can be removed.

How you can see in the demo (compare with your same code used original jquery.jqGrid.src.js) the changes fix the problem.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜