且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在jsp中没有选择的情况下获取jqgrid第一行数据?

更新时间:2022-11-03 12:02:34

要获取第一行的数据,可以在loadComplete

To get the data of first row you can use following in loadComplete

        //Call On JqGrid Load Complete
        loadComplete:function(data){
                    //id list value
                    var ids = $("#gridtable2").jqGrid('getDataIDs');
                    //get first id
                    var cl = ids[0];
                    var rowData = $(this).getRowData(cl); 
                    var temp= rowData['UserId']
            },

如果在loadComplete之外使用它,请使用:

And if you are using it outside of loadComplete use :

  var ids = $("#gridtable2").jqGrid('getDataIDs');
                //get first id
 var cl = ids[0];
    //fetch row data 
 var rowData = $("#gridtable2").getRowData(cl); 
    //fetch individual cell value
 var celValue = $("#gridtable2").jqGrid ('getCell', cl, 'UserId');

这是有效的 JSFIDDLE