저는 jqGrid에서 시작해 봅니다. Grid1에 2 개의 jqGrid가 있습니다. inCustom 및 OutCustom이 있습니다. Grid에서 사용자 클릭을 원한다면, inCustom 및 outCustom에서이 코드를 작성하십시오.데이터 행을 jqGrid에서 선택하는 방법
var grid = $('#list');
grid.jqGrid({
url: 'jQGridHandler.ashx',
postData: { ActionPage: 'ClearanceRequest', Action: 'Fill' },
ajaxGridOptions: { cache: false },
loadonce: true,
direction: "rtl",
datatype: 'json',
height: 600,
width: 1000,
colNames: ['', '', '', ' ', '', '', '', '', '',
'', '', ' ', '', '', '', '', '', '',
'', ' ', '', '', '', '',
'', '', '', '', '', '', ' ',
'', '', '', '', '', ''],
colModel: [
{ name: 'REQUEST_ID', width: 100, sortable: true, hidden: true },
{ name: 'REQUEST_DATE', width: 50, sortable: true },
{ name: 'REQUEST_NO', width: 60, sortable: true },
{ name: 'CUSTOMER_ID', width: 100, sortable: true },
{ name: 'TRANSPORT_TYPE', width: 40, sortable: true },
{ name: 'CLEARANCE_TYPE', width: 50, sortable: true },
{ name: 'IMPORT_EXPORT', width: 30, sortable: true, editable: false,
edittype: 'checkbox', editoptions: { value: "True:False" },
formatter: "checkbox", formatoptions: { disabled: false }, hidden: true
},
{ name: 'WAYBILL_NO', width: 50, sortable: true },
{ name: 'WAYBILL_OFFICE', width: 100, sortable: true },
{ name: 'MANIFEST', width: 200, sortable: true, hidden: true },
{ name: 'STORE_BILL', width: 100, sortable: true, hidden: true },
{ name: 'DIRECT_NO', width: 100, sortable: true, hidden: true },
{ name: 'STORE_DATE', width: 100, sortable: true, hidden: true },
{ name: 'INOUT_DATE', width: 50, sortable: true, hidden: true },
{ name: 'SOURCE_COUNTRY', width: 30, sortable: true, hidden: true },
{ name: 'SOURCE_CITY', width: 80, sortable: true, hidden: true },
{ name: 'DESTINATION_COUNTRY', width: 100, sortable: true, hidden: true },
{ name: 'IN_CUSTOMS', width: 200, sortable: true, hidden: true },
{ name: 'OUT_CUSTOMS', width: 100, sortable: true, hidden: true },
{ name: 'INSURER_ID', width: 100, sortable: true, hidden: true },
{ name: 'INSURANCE_NO', width: 100, sortable: true, hidden: true },
{ name: 'CLEARANCE_PERSON', width: 50, sortable: true, hidden: true },
{ name: 'PROXY_NO', width: 30, sortable: true, hidden: true },
{ name: 'FACTOR_NO', width: 80, sortable: true, hidden: true },
{ name: 'SHIP_NAME', width: 100, sortable: true, hidden: true },
{ name: 'TRAVEL_NO', width: 200, sortable: true, hidden: true },
{ name: 'INDENT_NO', width: 100, sortable: true, hidden: true },
{ name: 'COOTAG_NO', width: 100, sortable: true, hidden: true },
{ name: 'PERMIT_NO', width: 100, sortable: true, hidden: true },
{ name: 'CLEARANCE_NO', width: 50, sortable: true, hidden: true },
{ name: 'CARNETIR_NO', width: 30, sortable: true, hidden: true },
{ name: 'PURCHASE_TYPE', width: 80, sortable: true, hidden: true },
{ name: 'ALL_VALUE', width: 100, sortable: true, hidden: true },
{ name: 'FREIGHT_STATUS', width: 30, sortable: true, editable: false,
edittype: 'checkbox', editoptions: { value: "True:False" },
formatter: "checkbox", formatoptions: { disabled: false }, hidden: true
},
{ name: 'COPY_ORIGINAL', width: 30, sortable: true, editable: false,
edittype: 'checkbox', editoptions: { value: "True:False" },
formatter: "checkbox", formatoptions: { disabled: false }, hidden: true
},
{ name: 'REMARK', width: 100, sortable: true, hidden: true },
{ name: 'details', width: 20, sortable: false, search: false,
formatter: function() {
return "<span class='ui-icon ui-icon-document'></span>";
}
}
],
gridview: true,
rowNum: 30,
rowList: [30, 60, 90],
pager: '#pager',
sortname: 'WorkOrderNo',
viewrecords: true,
sortorder: 'ASC',
rownumbers: true,
beforeSelectRow: function (rowid, e) {
var iCol = $.jgrid.getCellIndex(e.target);
// alert(rowid);
console.log(rowid);
//listItem
console.log($.jgrid.getCellIndex(e.target));
if ($.jgrid.getCellIndex(e.target) == 37) {
$("#listItem").jqGrid("GridUnload");
var gridItem = $('#listItem');
gridItem.jqGrid({
url: 'jQGridHandler.ashx',
postData: { ActionPage: 'ClearanceItems', Action: 'Fill', requestId: rowid },
ajaxGridOptions: { cache: false },
loadonce: true,
direction: "rtl",
datatype: 'json',
height: 200,
colNames: ['', '', '', '', ' ', ' ', '',
'', '', 'ا', ' ', '', ' ',
'', '', ' ', ' ',
'', '', '', ' ', ' ', ' ', ' ', ''],
colModel: [
{ name: 'REQUEST_ID', width: 100, sortable: true },
{ name: 'ITEM_NO', width: 200, sortable: true },
{ name: 'GOODS_DESCRIPTION', width: 100, sortable: true },
{ name: 'QUANTITY', width: 100, sortable: true },
{ name: 'PACKING_TYPE', width: 100, sortable: true },
{ name: 'GROSS_WEIGHT', width: 50, sortable: true },
{ name: 'TARE_WEIGHT', width: 30, sortable: true },
{ name: 'MEASUREMENT_TYPE', width: 80, sortable: true, hidden: true },
{ name: 'GOODS_PRICE', width: 100, sortable: true, hidden: true },
{ name: 'GOODS_CURRENCY', width: 200, sortable: true, hidden: true },
{ name: 'GOODS_CURRENCY_RATE', width: 100, sortable: true, hidden: true },
{ name: 'FREIGHT_PRICE', width: 100, sortable: true, hidden: true },
{ name: 'FREIGHT_CURRENCY', width: 100, sortable: true, hidden: true },
{ name: 'FREIGHT_CURRENCY_RATE', width: 50, sortable: true, hidden: true },
{ name: 'INSURANCE_PRICE', width: 30, sortable: true, hidden: true },
{ name: 'INSURANCE_CURRENCY', width: 80, sortable: true, hidden: true },
{ name: 'INSURANCE_CURRENCY_RATE', width: 100, sortable: true, hidden: true },
{ name: 'TARIFF_NO', width: 200, sortable: true, hidden: true },
{ name: 'CUSTOM_PRICE', width: 100, sortable: true, hidden: true },
{ name: 'WARRANTY_PRICE', width: 100, sortable: true, hidden: true },
{ name: 'INOUT_DATE', width: 100, sortable: true, hidden: true },
{ name: 'VEHICLE_TYPE', width: 50, sortable: true, hidden: true },
{ name: 'VEHICLE_NO', width: 30, sortable: true, hidden: true },
{ name: 'WAREHOUSE_ID', width: 80, sortable: true, hidden: true },
{ name: 'REMARK', width: 80, sortable: true, hidden: true }
],
gridview: true,
rowNum: 20,
rowList: [20, 40, 60],
pager: '#pagerItem',
viewrecords: true,
sortorder: 'ASC',
rownumbers: true
});
gridItem.jqGrid('navGrid', '#pagerItem', { add: true, edit: true, del: true },
{}, {}, {}, { multipleSearch: true, overlay: false, width: 460 });
var myGrid = grid;
var selRowId = myGrid.jqGrid('getGridParam', 'selrow');
celValue = myGrid.jqGrid('getCell', selRowId, 'IN_CUSTOMS');
celValue2 = myGrid.jqGrid('getCell', selRowId, 'OUT_CUSTOMS');
console.log(celValue);
console.log(celValue2);
alert(celValue);
alert(celValue2);
$("#POPUP2").dialog({ width: 780 });
}
return true;
}
});
grid.jqGrid('navGrid', '#pager', { add: false, edit: false, del: true },
{}, {}, {}, { multipleSearch: true, overlay: false, width: 460 })
.navButtonAdd("#pager", {
caption: "",
buttonicon: "ui-icon-plus",
onClickButton: function() {
// alert("Adding Row");
$("#POPUP1").dialog({ width: 730 });
},
position: "first"
})
.navButtonAdd("#pager", {
caption: "",
buttonicon: "ui-icon ui-icon-pencil",
onClickButton: function() {
},
position: "first"
})
.navButtonAdd("#pager", {
caption: "",
buttonicon: "ui-icon ui-icon-trash",
onClickButton: function() {
},
position: "first"
});
detils 버튼의 첫 번째 클릭이 거짓 값을 얻을하지만 결국 모든
@ Oleg : 도움 주셔서 감사합니다. 코드를 추적하고 사용자가 세부 정보를 클릭하면 처음에는 값이 null입니다.하지만 값이 null인데 행을 선택했지만 사용자가 두 번째로 클릭했을 때 클릭합니다. 올바른 데이터를 가져옵니다. 올바른 데이터를 반환합니다. 올바른 데이터를 반환합니다. 도와주세요. 감사. – Pouya
@MohsenBahrzadeh : 내 대답의 첫 번째 문장에서 나는 행이 선택되기 전에 ** beforeSelectRow' 콜백을 사용하기 때문에 **라고 말했습니다. 이 문제를 해결하는 가장 간단한 방법은'beforeSelectRow : function (rowid, e) {...}'대신'onSelectRow : function (id, state, e) {...}'를 사용하는 것입니다. – Oleg