jqGrid新手。到目前为止,我正在显示一个网格,但现在在一列中有一个复选框。但是,复选框不会生成id或name属性 - 根据文档的不同。获得身份证的任何先决条件?理想情况下,我想要一个复选框上的id,就像前缀+ rowid一样。
代码是:
jQuery("#grdProducts").jqGrid(
{
url: '<%: Url.Action( "GetPageByCode", "Products" ) %>',
datatype: "xml",
mtype: 'POST',
colNames: [ 'Code', 'Language', 'Type', 'Name', 'Price £', 'Web', 'Dimensions', 'Actions' ],
colModel:
[
{ name: 'code', index: 'ProductCode', width: 120, key: true },
{ name: 'language', index: 'Category1', width: 100 },
{ name: 'type', index: 'Category2', width: 140 },
{ name: 'name', index: 'Name', width: 240 },
{ name: 'price', index: 'PriceGross', width: 60, align: "right" },
{ name: 'web', width: 32, align: "center",
editable:true, edittype:'checkbox', editoptions: {value:"True:False" },
formatter: "checkbox", formatoptions: {disabled : false } },
{ name: 'dimensions', width: 120, sortable:false },
{ name: 'actions', width: 120, sortable:false }
],
height:660,
rowList:[ 20,50,100 ],
pager: '#pgrProducts',
sortname: 'ProductCode',
// speed improvement - as long as certain features not needed
gridview: true,
// shows the 'showing 1 - n of total' in the pager, ... and the text to display
viewrecords: true,
recordtext: "showing products {0} - {1} of {2}",
// alternate colour rows
altRows:true, altclass: 'gridAltRow',
// shows sort arrows in titles
viewsortcols: [ true ],
// the grid outer caption
caption: 'Products by product code',
// configurable page size
rowNum: <%: Model.PageSize %>,
// double click on a row goes to the edit row page
ondblClickRow: function( rowid )
{
document.location.href = '/Product/Edit/' + rowid;
}
}
);
} );
答案 0 :(得分:0)
为什么您需要在复选框中添加id
属性?如果您需要获取复选框,那么在您的情况下将非常简单,因为行中只有一个复选框,因此您可以使用
$('#' + rowid + ' input:checkbox')
如果您需要检测“click”事件,例如复选框,您可以在the answer的演示中找到相应的代码。