Hi, This should be quite simple but I could not find any code examples. I need to grab some values from the Parent row based on an "ActiveRow" in one of the Parent's Child rows. I did not see anything hanging off of the GridRow Class that would gain access to a Parent row.
Any help would be greatly appreciated! Thanks
Hi jdymond,
I would suggest that you try accessing the parent row in the ActiveCellChanged event. You could use something like the following code:
protected void WebHierarchicalDataGrid1_ActiveCellChanged(object sender, ActiveCellEventArgs e)
{
string text = ((Infragistics.Web.UI.GridControls.GridRecord)(((Infragistics.Web.UI.GridControls.ContainerGrid)(sender)).ParentRow)).Items[1].Value.ToString();
}
If you have any further questions please let me know.
Sorry, I should have been a little more clear. I have a label that looks like a button outside of the grid that will add a child row to the grid using client side JavaScript. As you know, in order to add a row, you need to establish a relationship between the child row and the Parent row in order to do an add on the client. This is why I need access to the Parent row in order to obtain some information from a few hidden columns. These will be used when populating my cellValues Array.
// Add row.var childGrid = _getChildGridView();childGrid.get_rows().add(cellValues);
Thanks. - Jason
Hi Jason,
When setting up the data source, you create the relationships between parent and child grid. So when adding new row, you wouldn’t need to establish such relationships. You could use code, similar to the following to add new rows:
var grid = $find("WebHierarchicalDataGrid1
var newRow = new Array(5, "Record 5");
var newChildRow = new Array(10, "Child Item");
//Adds a new row to the parent grid
grid.get_gridView().get_rows().add(newRow);
//Adds a new child row to row[0] of the parent grid
grid.get_gridView().get_rows().get_row(0).get_rowIslands()[0].get_rows().add(newChildRow);
Please let me know if this helps.
When you add a new row, do you have to execute commit() to send the data to the database?
Arman
Hi Arman,
You don't need to explicitly call commit, the changes will be saved to the datasource on the first postback.