我是 JQGrid 的新手。我创建了一个表格,其中每一行都包含一个编辑按钮。我想通过单击编辑按钮时选择特定行来向控制器发送一个值。我找了几个答案,但不太明白。我想在 UpdateRow 函数中发送数据。 这是我的 jq 网格代码。
var Integrate = function() {
function GetValue() {
$(function (){
$("#tblSelectIntegrations").jqGrid({
mtype: "GET",
url: "/Integrations/Detail",
datatype: "json",
async: false,
colNames: [
"ID","First Name", "Email Address","Edit"
],
colModel: [
{ key: false, name: "IntegrationId", index: "IntegrationId", editable: false, width: 200, hidden:true },
{ key: false, name: "IntegrationName", index: "IntegrationName", editable: false, width: 200, hidden:false },
{ key: false, name: "CompanyEmail", index: "CompanyEmail", editable: false, width: 200, hidden:false },
{
name: '',
key: false,
width: 25,
editable: true,
sortable: false,
formatter: function () {
return "<button type='button' data-toggle='modal' data-target='#exampleModalCenter' onclick='Integrate.UpdateRow.call(this, event)' class='fm-button ui-state-default ui-corner-all noPrint'><span class='ui-icon ui-icon-pencil'></span></button>";
}
}
],
pager: jQuery("#divSelect"),
rowNum: -1,
scroll: 0,
height: $(window).innerHeight() - 450,
width: "100%",
viewrecords: true,
caption: "Product",
emptyrecords: "No records to display",
jsonReader: {
root: "rows",
page: "page",
total: "total",
records: "records",
repeatitems: false,
Id: "0"
},
autowidth: true,
multiselect: false,
loadonce:true,
autoencode: true,
ajaxGridOptions: { cache: false }
}).navGrid("tblSelectIntegrations", { edit: false, add: false, del: false, search: false, refresh: false });
});
}
function UpdateRow() {
var appOrderId = $(this).closest("tr.jqgrow").attr("id");
ShowControls("/Integrations/Update/" + appOrderId);
}
return {
GetValue: GetValue,
UpdateRow:UpdateRow
}
}();