JqG​​rid选择当前数据

时间:2011-06-22 09:51:29

标签: jquery jqgrid

我正在使用jqGrid,我想在点击的行

上选择特定的列值

这是我正在做的事情,但我没有得到它。请帮忙。我想获得cfgId

$('#configDiv').empty();
            $('<div width="100%">')
            .attr('id','configDetailsGrid')
            .html('<table id="list1" width="100%"></table>'+
                    '<div id="gridpager"></div>'+
                '</div>')       
            .appendTo('#configDiv');    

            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:"right", hidden:true},
                  {name:'',index:'', width:15, align:"right",edittype:'checkbox',formatter: "checkbox",editoptions: { value:"True:False"},editable:true,formatoptions: {disabled : false}},
                  {name:'cfgName',index:'cfgName', width:90, align:"right"},
                  {name:'hostname',index:'hostname', width:90, align:"right"},
                  {name:'cfgDesc',index:'cfgDesc', width:90, align:"right"},
                  {name:'productId',index:'productId', width:60, align:"right"},
                  {name:'cfgType',index:'cfgType', width:60, align:"right"},
                  {name:'updateDate',index:'updateDate', width:120, align:"right"},
                  {name:'emailAddress',index:'emailAddress', width:120, align:"right"},
                  {name:'absolutePath',index:'absolutePath', width:90, align:"right", hidden:true},
              ],
              pager : '#gridpager',
              rowNum:10,
              scrollOffset:0,
              height: 'auto',

              autowidth:true,
              viewrecords: true,
              gridview: true,
              xmlReader: {
                  root : "list",
                  row: "com\\.abcd\\.db\\.ConfigInfo",
                  userdata: "userdata",
                  repeatitems: false
              },
              onSelectRow: function(id){
                  //var userdata = jQuery("#list").getGridParam('userData');
                  //var listid = jQuery('#list').getCell(id, "cfgid");
                  //var listid = $('#list').jqGrid('getCell', id, 'Name');
                  var abc=jQuery("#list").getRowData(id);
                  alert(abc.cfgId);
                  }

            });
            grid.jqGrid('navGrid','#gridpager',{edit:false,add:false,del:false});

1 个答案:

答案 0 :(得分:1)

使用此

onSelectRow: function(id){
                  var rowData = jQuery(this).getRowData(id); 
                  configid = rowData['cfgId'];

                  }