我是jqGrid的初学者,我想实现内联编辑,并编写以下代码:
var gridDocument = jQuery("#listDocument");
gridDocument.jqGrid({
url: 'jQGridHandler.ashx',
postData: { ActionPage: 'ClearanceRequestDocument', Action: 'Fill', RequestId: '3' },
ajaxGridOptions: { cache: false },
loadonce: true,
direction: "rtl",
datatype: 'json',
height: '490',
colNames: ['DocumentNO', 'Documentname', 'OrginalCertificate', ' CopyCertificate', 'Remark'],
colModel: [
{ name: 'DOCUMENT_ID', width: 200, sortable: true, hidden: true },
{ name: 'DOCUMENT_NAME', width: 200, sortable: true, editable: false },
{
name: 'Orignal', width: 80, fixed: true, align: 'center', resizable: false, sortable: false,
formatter: function (cellValue, option, rowObject) {
return '<input id="t2" type="radio" name="radio_' + rowObject + '" />';
}
},
{
name: 'Copy', width: 80, fixed: true, align: 'center', resizable: false, sortable: false,
formatter: function (cellValue, option, rowObject) {
return '<input id="t1" type="radio" name="radio_' + rowObject + '" />';
}
},
// { name: 'is_ORGINAL', width: 80, sortable: true, editable: true, formatter: 'checkbox', edittype: 'checkbox', editoptions: { value: 'Yes:No', defaultValue: 'Yes'} },
//{ name: 'is_copy', width: 80, sortable: true, editable: true, formatter: 'checkbox', edittype: 'checkbox', editoptions: { value: 'Yes:No', defaultValue: 'Yes'} },
{ name: 'REMARK', width: 200, sortable: true, editable: false }
],
sortname: 'DOCUMENT_ID',
viewrecords: true,
rownumbers: true,
sortorder: "desc",
editurl: 'clientArray',
altRows: true,
altclass: 'ui-priority-secondary',
onSelectRow: function (id) {
if (id && id !== lastSel) {
gridDocument.saveRow(lastSel, true, 'clientArray');
gridDocument.jqGrid('restoreRow', lastSel);
gridDocument.jqGrid('editRow', id, true, null, null, 'clientArray');
lastSel = id;
intArray[index] = id;
index += 1;
}
},
pager: '#pagerDocument',
rowNum: 30,
rowList: [30, 60, 90],
loadComplete: function () {
var $this = $(this), ids = $this.jqGrid('getDataIDs'), i, l = ids.length;
for (i = 0; i < l; i++) {
$this.jqGrid('editRow', ids[i], true);
}
}
}).jqGrid('navGrid', '#pagerDocument', { edit: false, add: false, del: false, search: false, refresh: false });在这个网格中,我有2个radioButton列。我想让用户确定这个证书提供的证据是原始的还是复制的,我尝试通过这个代码获取值radioButton (选中或未选中)
for (var i = 0; i < $("#listDocument").getGridParam("reccount") ; i++) {
var row = $("#listDocument").jqGrid('getRowData', i + 1);
alert($(row.Orignal).is(":checked") + "|" + row.Copy);
}这段代码总是警告假值,请帮我写这段代码,谢谢各位专家。
发布于 2013-01-24 13:37:23
如果要根据原始值(true或false)选中该单选按钮
将格式化程序函数从
formatter: function (cellValue, option, rowObject) {
return '<input id="t2" type="radio" name="radio_' + rowObject + '" />';
}至
formatter: function (cellValue, option, rowObject) {
return '<input id="t2" type="radio" name="radio_' + rowObject["DOCUMENT_ID"] + '" checked="'+cellvalue+'"/>';
}我不明白您为什么要将rowobject附加到name
更新:
我以为你想在装货的时候检查一下单选按钮。如果要确保在内联编辑时只选中一个单选按钮,则可以使用自定义验证。
使用自定义函数验证原件和副本(对两列使用相同的函数)
use editrules:{custom: true, custom_func: validateOriginalOrCopy}在custom_func中有两个参数,传递的是value和colname,您可以使用这些参数进行验证
https://stackoverflow.com/questions/14481403
复制相似问题