2012-02-19 90 views
0

我面临jqGrid的问题。我在jqGrid中有一个文档列表。第一列DocID,第二列是DocName,现在我需要两个带有复选框的列,以便用户可以订阅这些文档。因此,我需要第3列和第4列的复选框,以便用户可以选中任意数量的复选框,然后每次点击需要使用文档ID进行AJAX调用的复选框,以便我可以保存用户订阅的该用户的选项那个具体的文件。带有复选框的jqGrid列

我可以使两列与复选框,我使用启用他们与格式化,但现在我不能走得更远,我需要获取rowid点击复选框和行的文档ID在哪里复选框被点击。

这是我的网格代码。

jQuery("#doc").jqGrid({ 
    url: urlDoc + docID, 
    datatype: 'json', 
    mtype: 'GET', 
    colNames:[<?php echo (buildCSV(array(_(''), _('Document ID'), _('Document Name'), _('Subscribe'), _('Copy Locally')))); ?>], 
    colModel:[ 
      {name:'fld_doc2comp_status',index:'fld_doc2comp_status', width:1, editable: false, align:"left", hidden:true}, 
      {name:'fld_comp_documentid',index:'fld_comp_documentid', width:70, editable: true, align:"left", sortable:false, 
       editrules:{required:true}, formoptions:{label:'<?php echo (_('Document ID') . ' *');?>'} }, 
      {name:'fld_documentname',index:'fld_documentname', editable: true, align:"left", sortable:false, 
      editrules:{required:true}, formoptions:{label:'<?php echo (_('Document Name') . ' *');?>'} }, 
      {name:'fld_subscribe',index:'fld_subscribe', editable: true, formatter:'checkbox', edittype:"checkbox", formatoptions:{disabled:false}, sortable:false, width:60, align:"center"}, 
      {name:'fld_local',index:'fld_local', editable: true, formatter:'checkbox', edittype:"checkbox", formatoptions:{disabled:false}, sortable:false, width:60, align:"center"} 
    ], 
    loadComplete: function() { 
     jQuery('#doc').setSelection(jQuery('#doc').getDataIDs()[0],true); 
     $('.ui-jqgrid-titlebar-close').remove(); 
    }, 
    onSelectRow: function(id){ 
     docID=id; 
    }, 
    width:650, 
    height:430, 
    rowNum:100, 
    viewrecords: true, 
    sortable: true, 
    sortname: 'fld_comp_documentid', 
    sortorder: 'asc', 
    pager:"#docpgr", 
    pgbuttons:true, 
    pginput:true, 
    editurl: urlDoc + docID, 
    caption: '<?php echo _('Document');?>' 
}); 

我要救通过编辑记录画面fld_subscribe并在主屏幕上的数据库fld_local领域,而不是。我需要用户能够通过简单地点击复选框来更改任何文档的fld_local和fld_subscribe。

期待您的快速回复家伙。

回答

1

我建议您查看the answer,其中显示了如何将复选框上的点击绑定到您的事件处理程序。演示程序使用Tree Grid,但代码与任何jqGrid完全相同。

顺便说一下,loadComplete里面的this<table>的DOM。它有rows财产。 jqGrid的第一行是隐藏的空行。所以第一个可见行的id将是this.rows[1].id。您可以验证该this.rows.length > 1,然后使用this.rows[1].id而不是 jQuery('#doc').getDataIDs()[0]