0

我的 jqGrid 下面有两列(user_id 和 user_name)。我想通过页面 url 通过 GET 参数传递一个 USER_NAME,然后 jqGrid 移动到该值页面并显示该页面的所有记录。这是可能的,因为 jqGrid 每页只加载 25 条记录吗?

$(document).ready(function() { 


   $("#list").jqGrid(
   {
    url:'index.cfc?method=getData', //CFC that will return the users
    datatype: 'json', //We specify that the datatype we will be using will be JSON
    mtype: 'POST',
    colNames:['User ID', 'User Name'], //Column Names
    colModel :[     
     {name:'user_id',index:'user_id', sorttype:"string", formatter: 'showlink', formatoptions:{baseLinkUrl:'#'}},
     {name:'user_name',index:'user_name', sorttype:"string"}
    ],
    pager: $('#pager'), //The div we have specified, tells jqGrid where to put the pager
    toppager: true,
    height: 'auto',
    width: 1270,
    rowNum:25, //Number of records we want to show per page
    rowList:[25,50,100], //Row List, to allow user to select how many rows they want to see per page
    sortorder: "asc", //Default sort order
    sortname: "user_id", //Default sort column
    loadComplete: function() {
     var myGrid = $("#list");
     var ids = myGrid.getDataIDs();
     for (var i = 0, idCount = ids.length; i < idCount; i++) {
      $("#"+ids[i]+" a",myGrid[0]).click(function(e) {
       var hash=e.currentTarget.hash;// string like "#?id=0"
       if (hash.substring(0,5) === '#?id=') {
        var id = hash.substring(5,hash.length);
        var text = this.textContent;
        alert("clicked the row with id='"+id+"'. Link contain '"+text+"'");
        location.href="http://en.wikipedia.org/wiki/"+text;

       }
       e.preventDefault();

      });
     }  

     for(var i=0;i<ids.length;i++){ 
      var cl = ids[i]; 

       vdelete = "<a href='#' onclick=\"testfn('"+cl+"')\">Delete</a></ids>";  
       jQuery("#list").setRowData(ids[i],{act:vdelete}) 
     }     
    },
    caption: '', //Grid Name
    jsonReader: {
    root: "ROWS", //our data
    page: "PAGE", //current page
    total: "TOTAL", //total pages
    records:"RECORDS", //total records
    cell: "",
    id: "0"

    }
   })


   $("#list").jqGrid('navGrid','#pager',
   {
    edit:false,
    add:false,
    del:false, 
    search:true,
    refresh: true,
    searchtext:"Search",
    refreshtext: "Refresh",
    'cloneToTop':true
   }); 


  });
4

0 回答 0