2011-06-22 51 views
0

我正在使用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

使用此

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

        }