感谢大佬的资料https://blog.csdn.net/Easy_____/article/details/30218421
虽然没实例,但也给了一些信息。我以为cellsubmit属性是添加到colModel里面的!实际并不是,
而是添加到jqGrid里面
//加载Grid function LoadGrid() { $("#gridTable1").jqGrid({ datatype: "local", height: $(window).height() - 550, auto true, colModel: [ { label: "商品名称", name: "goodsName", index: "goodsName", 450, align: "center" }, { label: "商品Sku", name: "orderSku", index: "orderSku", 200, align: "center" }, { label: "商品件数", name: "count", index: "count", 90, align: "center" }, { label: "原始出厂单价", name: 'primitiveFactoryPrice', index: 'primitiveFactoryPrice', 200, sorttype: "float", align: "center" }, { label: "规格", name: 'spec', index: 'spec', 100, align: "center" }, { label: "单位", name: "unit", index: "unit", 50, align: "center" }, { label: "物流单号<font style="color:red;" face="宋体">*</font>", name: "waybill", index: "waybill", 200, align: "center" }, { label: "物流公司<font style="color:red;" face="宋体">*</font>", name: "company", index: "carrier", 200, align: "center" }, ], viewrecords: true, rowNum: 30, rownumbers: true, shrinkToFit: false, gridview: true, cellEdit: true, cellsubmit: "clientArray",//不需要传入后台 设置为clientArray。需要的时候可以设置为romote //gridComplete: function () { // var ids = jQuery("#gridTable1").jqGrid('getDataIDs'); // for (var i = 0; i < ids.length; i++) { // var cl = ids[i]; // var ae = '<input id="waybill_' + i + 1 + '" name="waybill_name" onchange="function(this){ $(this).attr("value", this.value);}" >'; // var be = '<input list="company_' + i + 1 + '_list" id="company_' + i + 1 + '" name="company_name" onchange="getCompany(this)"/><datalist id="company_' + i + 1 + '_list" style="display: none;"></datalist>'; // jQuery("#gridTable1").jqGrid('setRowData', ids[i], { company: be ,waybill:ae}); // } //} }); $("#gridTable1").setColProp("waybill", { editable: true });//设置列可编辑 $("#gridTable1").setColProp("company", { editable: true });//设置列可编辑 }
运行结果
我的jqGrid版本的colModel属性设置了editable并不支持
然后用setColProp方法才支持
$("#gridTable1").setColProp("waybill", { editable: true });//设置列可编辑
$("#gridTable1").setColProp("company", { editable: true });//设置列可编辑