我有类似的东西 如何按顺序将jqGrid数据传递给控制器。 我想将数据绑定到控制器中的另一个网格,只有“Requision List”的第一行传递给控制器并且它绑定“Requision Material List”中的数据 第二行数据没有通过。
ReqNoGridBind for Requision List中的绑定:
function ReqNoGridBind(condiA) {
if (condiA == 'empty' || condiA == 'enablefill' || condiA == 'disablefill') {
var FrmdateA = ""; var ToDateA = "";
var sStatus = gact;
if (condiA == 'empty') {
FrmdateA = ("" + $("#txtReqFromDt").val()).trim();
ToDateA = ("" + $("#txtReqToDt").val()).trim();
STranNo = ("" + $("#txtTranNo").val()).trim();
var urlq = "GetReqNoFrPO?FrmdateA=" + FrmdateA + "&&ToDateA=" + ToDateA + "&&STranNo=" + STranNo + "&&sStatus=" + sStatus;
}
else {
FrmdateA = "";
ToDateA = "";
STranNo = ("" + $("#txtTranNo").val()).trim();
var urlq = "GetReqNoFrPO?FrmdateA=" + FrmdateA + "&&ToDateA=" + ToDateA + "&&STranNo=" + STranNo + "&&sStatus=" + sStatus;
}
}
colnames = ['Req. Date', 'Requision No', 'From Store'];
$("#ReqNoGrid").jqGrid('GridUnload');
$("#ReqNoGrid").clearGridData();
$("#ReqNoGrid").jqGrid({
url: urlq,
datatype: 'json',
mtype: 'post',
colNames: colnames,
colModel: [
{ name: 'REQDATE', index: 'REQDATE', width: 80, editable: false },
{ name: 'REQNO', index: 'REQNO', width: 120, editable: false },
{ name: 'FRMSTORE', index: 'FRMSTORE', width: 180, editable: false }
],
sortname: 'id',
sortorder: 'desc',
shrinkToFit: false,
hidegrid: false,
gridView: true,
rownumbers: true,
loadonce: true,
multiselect: true,
sortableColumns: false,
cellsubmit: 'clientArray',
height: 133,
width: 316,
rowNum: 9999999999,
ondblClickRow: true,
loadtext: 'Loading.....',
footerrow: false,
gridComplete: function () {
var n, SaveRowData = "";
if (condiA == 'empty') {
condiA = 'clear';
var ids = jQuery("#ReqNoGrid").jqGrid('getDataIDs');
var i = 0
for (i = 0;i<selRowIds.length;i++) {
if (ids.length == 0) {
jQuery("#ReqNoGrid").jqGrid('addRowData', selRowIds[i].REQNO, selRowIds[i]);
}
else {
if (ids.indexOf(selRowIds[i].REQNO) == -1) {
jQuery("#ReqNoGrid").jqGrid('addRowData', selRowIds[i].REQNO, selRowIds[i]);
}
}
}
var ids = jQuery("#ReqNoGrid").jqGrid('getDataIDs');
if (ids.length >= 0) {
var MtrlIds = jQuery("#ReqMtrl").jqGrid('getCol', 'REQNO');
if (MtrlIds.length >= 0) {
for (j = 0; j <= MtrlIds.length; j++) {
for (var i = 0; i < ids.length; i++) {
if (MtrlIds[j] == ids[i]){
$(this).find('>tbody>tr.jqgrow>td>input[type="checkbox"]')[i].checked = true;
$(this).disableSelection();
}
}
}
}
}
}
else if (condiA == 'disablefill') {//condiA != 'empty' && condiA != ''
var ids = jQuery("#ReqNoGrid").jqGrid('getDataIDs');
if (ids.length >= 0) {
$("#ReqMtrl").jqGrid('GridUnload');
$("#ReqMtrl").clearGridData();
for (var i = 0; i < ids.length; i++) {
$(this).find('>tbody>tr.jqgrow>td>input[type="checkbox"]')[i].checked = true;
LstReq = LstReq + "-" + ids[i];
}
if (gact == "E") {
ReqMtrlBindVerifyDis('enablefill', '', ids[i]);
}
else if (gact == "C" || gact == "P" || gact == "F" || gact == "O" || gact == "D") {
ReqMtrlBindVerifyDis('disablefill', '', ids[i]);
}
}
}
if (condiA == 'disablefill') {// || condiA =='empty'
var cbs = $("tr.jqgrow > td > input.cbox", $("#ReqNoGrid")[0]);
var hbs = $("tr.ui-jqgrid-labels > th > div > input.cbox", $("#ReqNoGrid")[0]);
cbs.prop("disabled", "disabled");
hbs.prop("disabled", "disabled");
}
},
beforeSelectRow: function (rowid, e) {
if (e.target.type == 'checkbox' && e.toElement.cellIndex == undefined) {
if (e.target.checked == true) GetReqMtrlForPO(rowid);
else RmvMtrlForReqNo(rowid);
}
},
}).trigger("reloadGrid");
$("#cb_ReqNoGrid")[0].style.display = 'none';
$('.ui-jqgrid-sdiv').removeClass('ui-widget-content');
$("#ReqNoGrid").parents('div.ui-jqgrid-bdiv').css("overflow-y", "scroll");
}
这是针对“Requision Material List”
function ReqMtrlBindVerifyDis(condiA, rowId, Reqno) {
if (condiA == 'empty' || condiA == 'enablefill' || condiA == 'disablefill') {
if (condiA != 'empty') {
sStatus = gact;
ReqNo = Reqno;
PONO = ("" + $("#txtTranNo").val()).trim();
VendCode = ("" + $("#txtSupplierCode").val()).trim();
var urlq = 'GetReqMtrlForPO?ReqNo=' + ReqNo + '&&PONO=' + PONO + '&&VendCode=' + VendCode + '&&Status=' + gact + '&&ListOfReq=' + LstReq;
}
}
colnames = ['Requision No', 'Material Code', 'Material Name', 'Unit', 'HSN Code', 'Order Qty.', 'Remain Qty.', 'PO Qty.', 'Free Qty.', 'Rate', 'Conv. Fact', 'Amount', 'DiscPer', 'DiscAmt', 'CSTPer', 'CSTAmt', 'VATPer', 'VATAMT', 'GSTPer', 'GSTAmt', 'IGSTPer', 'IGSTAmt', 'ImpDutyPer', 'ImpDutyAmt', 'FrieghtPer', 'FrieghtAmt', 'OctPer', 'OctAmt', 'OtherAmt', 'InshuPer', 'InshuAmt', 'CshDiscPer', 'CshDiscAmt', 'Less Amt', 'Round Amt', 'Net Amt', 'MRP', 'VATCALC', 'UnitCode', 'CHECKED', 'RATECNTRT', 'Tick'];
//$("#ReqMtrl").jqGrid('GridUnload');
//$("#ReqMtrl").clearGridData();
$("#ReqMtrl").jqGrid({
url: urlq,
datatype: 'json',
mtype: 'post',
async: true,
colNames: colnames,
colModel: [
{ name: 'REQNO', index: 'REQNO', width: 120, eidtable: false },
{ name: 'MTRLCODE', index: 'MTRLCODE', width: 100, editable: false },
{ name: 'MTRLNAME', index: 'MTRLNAME', width: 200, editable: false },
{ name: 'UNIT', index: 'UNIT', width: 100, editable: false },
{ name: 'HSNCODE', index: 'HSNCODE', width: 100, editable: false },
{ name: 'ORDQTY', index: 'ORDQTY', width: 100, eidtable: false, align: 'center' },
{ name: 'REMAINQTY', index: 'REMAINQTY', width: 100, editable: false, align: 'center' },
{ name: 'POQTY', index: 'POQTY', width: 100, editable: false, cellEdit: true, align: 'right' },
{ name: 'FREEQTY', index: 'FREEQTY', width: 100, editable: false, hidden: true },
{ name: 'RATE', index: 'RATE', width: 100, editable: false, hidden: true },
{ name: 'CONVFACT', index: 'CONVFACT', width: 100, editable: false, hidden: true },
{ name: 'AMOUNT', index: 'AMOUNT', width: 100, editable: false, hidden: true },
{ name: 'DISCPER', index: 'DISCPER', width: 100, editable: false, hidden: true },
{ name: 'DISCAMT', index: 'DISCAMT', width: 100, editable: false, hidden: true },
{ name: 'CSTPER', index: 'CSTPER', width: 100, editable: false, hidden: true },
{ name: 'CSTAMT', index: 'CSTAMT', width: 100, editable: false, hidden: true },
{ name: 'VATPER', index: 'VATPER', width: 100, editable: false, hidden: true },
{ name: 'VATAMT', index: 'VATAMT', width: 100, editable: false, hidden: true },
{ name: 'GSTPER', index: 'GSTPER', width: 100, editable: false, hidden: true },
{ name: 'GSTAMT', index: 'GSTAMT', width: 100, editable: false, hidden: true },
{ name: 'IGSTPER', index: 'IGSTPER', width: 100, editable: false, hidden: true },
{ name: 'IGSTAMT', index: 'IGSTAMT', width: 100, editable: false, hidden: true },
{ name: 'IMPDUTYPER', index: 'IMPDUTYPER', width: 100, editable: false, hidden: true },
{ name: 'IMPDUTYAMT', index: 'IMPDUTYAMT', width: 100, editable: false, hidden: true },
{ name: 'FRIEGHTPER', index: 'FRIEGHTPER', width: 100, editable: false, hidden: true },
{ name: 'FRIEGHTAMT', index: 'FRIEGHTAMT', width: 100, editable: false, hidden: true },
{ name: 'OCTPER', index: 'OCTPER', width: 100, editable: false, hidden: true },
{ name: 'OCTAMT', index: 'OCTAMT', width: 100, editable: false, hidden: true },
{ name: 'OTHERAMT', index: 'OTHERAMT', width: 100, editable: false, hidden: true },
{ name: 'INSHUPER', index: 'INSHUPER', width: 100, editable: false, hidden: true },
{ name: 'INSHUAMT', index: 'INSHUAMT', width: 100, editable: false, hidden: true },
{ name: 'CSHDISCPER', index: 'CSHDISCPER', width: 100, editable: false, hidden: true },
{ name: 'CSHDISCAMT', index: 'CSHDISCAMT', width: 100, editable: false, hidden: true },
{ name: 'LESSAMT', index: 'LESSAMT', width: 100, editable: false, hidden: true },
{ name: 'ROUNDAMT', index: 'ROUNDAMT', width: 100, editable: false, hidden: true },
{ name: 'NETAMT', index: 'NETAMT', width: 100, editable: false, hidden: true },
{ name: 'MRP', index: 'MRP', width: 100, editable: false, hidden: true },
{ name: 'VATCALC', index: 'VATCALC', width: 100, editable: false, hidden: true },
{ name: 'UNITCODE', index: 'UNITCODE', width: 100, editable: false, hidden: true },
{ name: 'CHECKED', index: 'CHECKED', width: 100, editable: false, hidden: true },
{ name: 'RATECNTRT', index: 'RATECNTRT', width: 100, editable: false, hidden: true },
{ name: 'TICK', index: 'TICK', width: 100, editable: false, hidden: true }
],
sortname: 'id',
sortorder: 'desc',
shrinkToFit: false,
hidegrid: false,
gridview: true,
rownumbers: true,
loadonce: true,
multiselect: true,
sortableColumns: false,
cellsubmit: 'clientArray',
height: 154,
width: 496,
cellEdit: true,
rowNum: 999999999999,
ondblClickRow: true,
loadtext: 'Loading...',
footerrow: false,
gridComplete: function () {
var ids = jQuery("#ReqMtrl").jqGrid('getDataIDs');
if (ids.length >= 0) {
for (var i = 0; i < ids.length; i++) {
var rwReqMtrl = $('#ReqMtrl').getRowData(ids[i]);
if (("" + rwReqMtrl.TICK).trim() == "1") $(this).find('>tbody>tr.jqgrow>td>input[type="checkbox"]')[i].checked = true;
}
if (condiA == 'disablefill') {
var cbs = $("tr.jqgrow > td > input.cbox", $("#ReqMtrl")[0]);
var hbs = $("tr.ui-jqgrid-labels > th > div > input.cbox", $("#ReqMtrl")[0]);
cbs.prop("disabled", "disabled");
hbs.prop("disabled", "disabled");
}
}
},
beforeSelectRow: function (rowid, e) {
if (condiA != 'disablefill') {
if (e.target.type == 'checkbox' && e.toElement.cellIndex == undefined) {
var rwReqMtrl = $('#ReqMtrl').getRowData(rowid);
if (e.target.checked == true) {
rwReqMtrl.TICK = "1"; AddMtrlInPOMtrl(rowid);
if (lastSelReq != '') jQuery("#ReqMtrl").jqGrid('saveRow', lastSelReq);
jQuery("#ReqMtrl").jqGrid('editRow', rowid);
lastSelReq = rowid;
}
else {
rwReqMtrl.TICK = "0"; RmvMtrlInPOMtrl(rowid);
if (lastSelReq != '') jQuery("#ReqMtrl").jqGrid('saveRow', lastSelReq);
}
}
else if (e.target.type == undefined && e.toElement.cellIndex == 8) {
if (lastSelReq != '') jQuery("#ReqMtrl").jqGrid('saveRow', lastSelReq);
var rwReqMtrl = $('#ReqMtrl').getRowData(rowid);
if (rwReqMtrl.TICK = "1") {
jQuery("#ReqMtrl").jqGrid('editRow', rowid);
lastSelReq = rowid;
}
}
}
},
onSelectAll: function (aRowids, status) {
for (j = 0; j < aRowids.length; j++) {
var rwReqMtrl = $('#ReqMtrl').getRowData(aRowids[j]);
if (status) { rwReqMtrl.TICK = "1"; AddMtrlInPOMtrl(aRowids[j]); }
else { rwReqMtrl.TICK = "0"; RmvMtrlInPOMtrl(aRowids[j]); }
}
},
}).trigger("reloadGrid");
$('.ui-jqgrid-sdiv').removeClass('ui-widget-content');
}