Accessing JqGrid selected value outside OnSelectRow
i have a Jqgrid with a subgrid. on sub grid i applied the add and delete functionality with asp.net mvc 3. the code is below:
onSelectRow: function () {
var myGrid = $("#" + subgrid_table_id),
selRowId = myGrid.jqGrid('getGridParam', 'selrow'),
celValue = myGrid.jqGrid('getCell', selRowId, 'PermissionID');
permissionID = celValue;
}
});
$("#" + subgrid_table_id).jqGrid('navGrid', '#' + subgrid_div_id,
{ add: true, del: true, edit: false, search: false },
{ width: '250', url: '@Url.Action("Update", "Role")' },
{ width: '250', url: '/Controler/Action/' + row_id },
{ width: '250', url: "/Controler/Action//" + row_id + "/" + permissionID });
the permissionID is globally defined as 0. but when i pressed De开发者_JAVA技巧lete button of grid its not passing the new value of permissionID to controller. when i debug it its changing the permissionID successfully.
does anyone know whats the issue ?
Thanks
Resolve by a little different scenario, thanks to Oleg . code is below:
$("#" + subgrid_table_id).jqGrid('navGrid', '#' + subgrid_div_id,
{ add: true, del: false, edit: false, search: false },
{ width: '250', url: '/Controler/Action' },
{ width: '250', url: '/Controler/Action/' + row_id })
.navButtonAdd('#' + subgrid_div_id, {
caption: '',
tooltip: 'Delete row',
buttonicon: "ui-icon-trash",
onClickButton: function () {
var myGrid = $("#" + subgrid_table_id);
var selRowId = myGrid.jqGrid('getGridParam', 'selrow');
var celValue = myGrid.jqGrid('getCell', selRowId, 'PermissionID');
if (selRowId === null && celValue === false) {
alert("Please select row");
return;
}
$.post("/Controler/Action",{"roleid":id1,"id2":selRowId,"id3":celValue},
function (data) {
if (data == true) {
alert("Association Deleted");
$("#" + subgrid_table_id).trigger("reloadGrid");
}
else {
alert("An error occured");
}
});
},
position: 'last'
});
精彩评论