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.
I think this is close... However, please consider this example. we have a grid with a Customer (Parent), Orders (Children) relationship. Once the page is rendered to the client, the user is able to expand the grid on any Parent Row or we may choose to expand the entire grid by default. That all depends on how we want to display the data to the user.
If the user clicks on a label outside of the grid, we then call a Client Side JavaScript Function and obtain the ActiveRow. If the ActiveRow happens to be a "Child Row", there are a few hidden columns in the ActiveRow's Parent Row that we would like obtain and use as default values for the New Row we are about to add to the ActiveRow's Parent Child Rows.
If you need any further assistance on the matter please do not hesitate to ask.
Hello Jason,
The parent row of an active cell could be accessed from the ActiveCellChanged event handler, using the following code:
function WebHierarchicalDataGrid1_Activation_ActiveCellChanged(sender, eventArgs)
var parentRow = eventArgs.getActiveCell().get_row().get_grid().get_parentRow();
var parentRowCell0 = parentRow.get_cell(0);
On a button click you could get the active cell and its parent row the following way:
function btnClicked() {
var grid = $find("WebHierarchicalDataGrid1");
var activeCell = grid.get_gridView().get_behaviors().get_activation().get_activeCellResolved();
var parentRow = activeCell.get_row().get_grid().get_parentRow();
If you have any further questions, please let me know.