I have those 2 Json data lists to populate JqGrid and subgrid :
This one for the main grid :
{'id': 1, 'first_name': 'Greg', 'last_name': 'JEAN'},
{'id': 2, 'first_name': 'Paul', 'last_name': 'Martin'},
{'id': 3, 'first_name': 'Georges', 'last_name': 'Linc'},
{'id': 4, 'first_name': 'Bill', 'last_name': 'Evans'}
And this one for the subgrid :
{'idref': 1, 'flavour': 'chocolate', 'temp': 'true'},
{'idref': 2, 'flavour': 'vanilla', 'temp': 'false'},
{'idref': 2, 'flavour': 'peanut', 'temp': 'false',
{'idref': 4, 'flavour': 'mint', 'temp': 'false'}
What i'm trying to do is, IF there is a match between ID and IDREF, populate the subgrid only with the matching datas. If there is no match I don't want any subgrid to appear (like in ID 3 in my example)
The expected result would be like :
I know i could use isHasSubGrid
but i don"t know how to write the "matching" condition between the 2 data lists.
This is how my code look like so far :
var available_lessons_json = {{available_lessons|safe}}
var subavailable_lessons_json = {{subavailable_lessons|safe}}
$("#jqGrid").jqGrid({
datatype: 'local',
data: available_lessons_json,
colModel: [
{name: 'id', label : 'id'},
{name: 'first_name', label : 'first_name'},
{name: 'last_name', label : 'last_name'}
],
loadonce: true,
viewrecords: true,
width: 780,
height: 200,
rowNum: 20,
rowList : [20,30,50],
altRows: true,
rownumbers: true,
rownumWidth: 25,
subGrid: true,
subGridRowExpanded: showChildGrid,
subGridOptions : {
// configure the icons from theme rolloer
plusicon: "ui-icon-triangle-1-e",
minusicon: "ui-icon-triangle-1-s",
openicon: "ui-icon-arrowreturn-1-e"
},
pager: "#jqGridPager"
});
function showChildGrid(parentRowID, parentRowKey) {
var childGridID = parentRowID + "_table";
var childGridPagerID = parentRowID + "_pager";
var childGridURL = parentRowKey+".json";
$('#' + parentRowID).append('<table id=' + childGridID + '></table><div id=' + childGridPagerID + ' class=scroll></div>');
$("#" + childGridID).jqGrid({
url: childGridURL,
datatype: 'local',
data: subavailable_lessons_json,
page: 1,
colModel: [
{name: 'idref', label : 'idref'},
{name: 'flavour', label : 'flavour'},
{name: 'temp', label : 'temp'}
],
loadonce: true,
width: 500,
height: '100%',
pager: "#" + childGridPagerID,
});
}
Any help would be welcome.
Thanks in advance