In my ASP.NET MVC application, I have JQGrid and its SubGrid but I noticed on onSelectRow
event it is not detecting Subgrid rows until I expand main grid rows. I am trying to select main grid row and on select, all sub grid row's checkbox should be selected. But it is not finding any SubGrid. But when I expand then it works. Am I missing any property of Grid or Subgrid?
$("#MyGrid").jqGrid({
datatype: 'local',
colModel: [
{
name: 'ColSelected', label: ' ', width: 40, sortable: false,
formatter: 'checkbox', align: 'center', formatoptions: { disabled: false },
editable: true, edittype: "checkbox", editoptions: { value: "Yes:No", defaultValue: "Yes" }
},
{ name: 'ColName', label: 'Column Name', width: 340, editable: false, sortable: false }],
height: '100%',
autowidth: true,
multiselect: false,
beforeSelectRow: function (rowid, event) {
//some of my code
return true;
},
onSelectRow: function (rowid, status, event) {
//some of my code
},
gridComplete: function () {
//some of my code
},
loadComplete: function () {
//some of my code
},
subGrid: true,
subGridOptions: {
"plusicon": "ui-icon-triangle-1-e",
"minusicon": "ui-icon-triangle-1-s",
"openicon": "ui-icon-arrowreturn-1-e",
"reloadOnExpand": false,
"selectOnExpand": false
},
subGridRowExpanded: function (subgrid_id, row_id) {
var subgrid_table_id = subgrid_id + "_t",
pager_id = "p_" + subgrid_table_id,
localRowData = $(this).jqGrid("getLocalRow", row_id);
$("#" + subgrid_id).html("<table id='" + subgrid_table_id + "'></table><div id='" + pager_id + "'></div>");
$("#" + subgrid_table_id).jqGrid({
datatype: "local",
data: localRowData.LanguageNames,
colNames: [' ', 'Languages'],
colModel: [
{
name: 'ColSelected', label: ' ', width: 40, sortable: false,
formatter: 'checkbox', align: 'center', formatoptions: { disabled: false },
editable: true, edittype: "checkbox", editoptions: { value: "Yes:No", defaultValue: "Yes" }
},
{ name: 'Language', label: 'Languages', align: 'center', width: 150 }
],
idPrefix: "s_" + row_id + "_",
pager: "#" + pager_id,
autowidth: true,
sortname: "num",
sortorder: "asc",
height: "55",
beforeSelectRow: function (rowid, event) {
//some of my code
return true;
},
onSelectRow: function (rowid) //some of my code
},
loadComplete: function () {//some of my code
}
}).jqGrid('navGrid', "#" + pager_id, { edit: false, add: false, del: false });
}
});