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);
});
Thanks Tsanna,
Specifically, I want to create a hyperlink column in a child row, which uses a parent row cell value in the querystring of the target path.
In the code below, I am setting the Template property of the 'Details' column in ColumnLayouts, but I am unable to capture 'Simulation_id' from the parent level.
@(Html.Infragistics().Grid<Contract>()
.ID("gridContracts")
.Width("100%")
.Height("600px")
.AutoGenerateColumns(true)
.AutoGenerateLayouts(true)
.PrimaryKey("Contract_id")
.Columns(cols =>
cols.For(x => x.Simulation_id).HeaderText("").Width("100px");
cols.For(x => x.Contract_id).HeaderText("").Width("100px");
cols.For(x => x.ContractName).HeaderText("Contract");
})
...
.ColumnLayouts(layouts =>
layouts.For(x => x.Versions)
.PrimaryKey("Version_id")
.ForeignKey("Contract_id")
cols.For(x => x.Details).HeaderText("Details").HeaderText("").Width("100px")
.Template("<a href=\"Provision.aspx?s_id=${parent.Simulation_id}&v_id=${Version_id}\" target=\"_self\">Details</a>");
.DataSource(Model)
.DataBind()
.Render()
)