大家好我有jqgrid并设置更新内联。我写了这段代码
$(function () {
var localstr="2:Dolar;3:Pond;4:Rial";
var rows;
var lastSel;
var grid = $('#list');
grid.jqGrid({
url: 'jQGridHandler.ashx',
postData: { ActionPage: 'ClearanceCost', Action: 'Fill' },
ajaxGridOptions: { cache: false },
loadonce: true,
direction: "rtl",
datatype: 'json',
height: 490,
colNames: ['RequestId', 'WaybillNo', 'CostId', 'NameCost', 'Amount', 'CurrencyTypeId ', 'Remark'],
colModel: [
{ name: 'REQUEST_ID', width: 100, sortable: true, hidden: true },
{ name: 'WAYBILL_NO', width: 100, sortable: true, hidden: true },
{ name: 'COST_ID', width: 200, sortable: true, hidden: true },
{ name: 'COST_NAME', width: 200, sortable: true },
{ name: 'COST_AMOUNT', width: 100, sortable: true, editable: true },
{ name: 'CURRENCY_ID', width: 100, sortable: true, editable: true, edittype: 'select', formatter: 'select', editoptions: {
value: localstr
//,
},
{ name: 'REMARK', width: 200, sortable: true, editable: true }
],
gridview: true,
rowNum: 30,
rowList: [30, 60, 90],
pager: '#pager',
sortname: 'REQUEST_ID',
viewrecords: true,
sortorder: 'ASC',
rownumbers: true,
loadComplete: function () {
var $this = $(this);
rows = this.rows;
var l = rows.length, i, row;
for (i = 0; i < l; i++) {
row = rows[i];
var selRowId = grid.jqGrid('getGridParam', row.id);
console.log(selRowId);
console.log(grid.jqGrid('getCell', row.id, 'CURRENCY_ID'));
if ($.inArray('jqgrow', row.className.split(' ')) >= 0) {
$this.jqGrid('editRow', row.id, true);
}
}
},
editurl: "jQGridHandler.ashx"
});
grid.jqGrid('navGrid', '#pager', { add: true, edit: true, del: true }, {}, {}, {}, { multipleSearch: true, overlay: false, width: 460 });
$("#btnsave").click(function () {
var l = rows.length, i, row;
for (i = 1; i < l; i++) {
row = rows[i];
// var $this = grid.jqGrid('getCell', row.id, 'COST_AMOUNT');
// var $id = $($this).attr("id");
// var COST_AMOUNT = $("#" + $id).val();
// console.log(grid.jqGrid('getCell', row.id, 'COST_ID'));
// $this = grid.jqGrid('getCell', row.id, 'COST_ID');
// $id = $($this).attr("id");
// var COST_ID = $("#" + $id).val();
alert(grid.jqGrid('getCell', row.id, 'CURRENCY_ID'));
// $this = grid.jqGrid('getCell', row.id, 'CURRENCY_ID');
// $id = $($this).attr("id");
// var CURRENCY_ID = $("#" + $id).val();
// $this = grid.jqGrid('getCell', row.id, 'REMARK');
// $id = $($this).attr("id");
// var REMARK = $("#" + $id).val();
// console.log(COST_ID + ", " + COST_AMOUNT + ", " + CURRENCY_ID + ", " + REMARK);
}
});
});
我想在用户点击btn时获取CURRENCY_ID下拉列表值,请帮助我。谢谢所有
EDIT01:
Oleg先生,我希望设计像this posted
感谢您的帮助
答案 0 :(得分:1)
可以看到您在JSON数据中使用了错误的列顺序。像“EURO”这样的文本位于第三列中,但您在第6位的网格中有列。一个人必须计算所有隐藏的列。也许您只需要更改列的顺序,然后在colModel
中的另一个位置移动“WAYBILL_NO”和“COST_ID”。
可能是你有错误吗?
此外,您不应忘记定义您使用的所有变量。例如行
var $this = $(this);
rows = this.rows;
应固定为
var $this = $(this),
rows = this.rows;
与
相同var $this = $(this), rows = this.rows;
当前代码
var $this = $(this);
window.rows = this.rows;
或在严格的JavaScript模式下产生错误。