Is it possible to reference parent row data in the column template of a child row?
I have tried, for example: ${parent.ColumnKey}, but this doesn't work.
Further, the grid is bound to a DataSet of (2) related DataTables.
Hello lwoodell,
It depends on what exactly you're aiming to achieve. From the grid API you can get more information about the events where is possible to access the parent row: http://help.infragistics.com/jQuery/2014.2/ui.ighierarchicalgrid#events Could you please explain me in more details what is your purpose in order to be more helpful for you?
Looking forward to your response.
Regards,
Tsanna
Tsanna,
Using the RowExpanding event of the igHierarchicalGrid, I was able to get the desired result. (See below)
If there is a better or more efficient way to achieve this, please let me know.
$("#gridContracts").on("ighierarchicalgridrowexpanding", function (evt, ui)
{
var parentRow = ui.parentrow;
var parentRowId = parentRow.attr("data-id");
// get the value from the parent row cell by column key
var simId = $("#gridContracts").igGrid("getCellValue", parentRowId, "Simulation_id");
// get a the child grid object
var childGrid = ui.owner.allChildrenWidgets()[0];
// set the column template
childGrid.setColumnTemplate(childGrid.options.columns[0].key, "<a href=\"targetpage.aspx?s_id=" + simId + "&v_id=${Version_id}\" target=\"_self\">Details</a>", true);
});
Update:
Due to the way that the allChildrenWidgets() method works, it was necessary to add a bit of code to retrieve the correct item from the array.
// get primary key value from parent row
var pk = $("#gridContracts").igGrid("getCellValue", parentRowId, "Contract_id");
var childGrids = ui.owner.allChildrenWidgets();
// loop thru array of allChildrenWidgets()
for (var i = 0; i < childGrids.length; i++)
// compare pk to fk of first row in each grid item
if (childGrids[i].getCellValue(childGrids[i].rows(0).attr("data-id"), "Contract_id") == pk)
childGrids[i].setColumnTemplate(childGrids[i].options.columns[0].key, "<a href=\"targetpage.aspx?s_id=" + sim_Id + "&v_id=${Version_id}\" target=\"_self\">Details</a>", true);
break;
}
Hello lwoodell ,
I am new to iggrid.
I can`t call the ighierarchicalgridrowexpanding event when i click the plus icon of the parent row. So, I used the rowExpanding event as below:
rowExpanding : function(e, args) {
rowExpanding :
function
(e, args) {
var parentRow = args.parentrow;
args
var pk = $("#gridId").igGrid("getCellValue", parentRowId, "ColumnKey");
Then, I got the following error:
Cannot read property dataType of null in infragistics.lob.js
May I know what is the data-id in following line:
Thanks
Thank you for your raply.
I haven`t got the solution yet.
I think the "data-id" row attribute is generated automatically when a primary key is assigned to the row, and correlates to the value of the PK.
In my example, I was dealing with a hierarchical grid bound to a dataset of related tables (PK/FK relation).