Hello,
I have created Grid with ViewType="Hierarchical",LoadOnDemand="XML".
and one asp button Show on page
On Show_click event I loop through Grid rows and checks which is selected, and then checks
if (oRow.HasChildRows)
this always return me false even if there r child rows for that selected rows.
I want loop through child rows of selected row of first band and collect some data.It is not working
But if set LoadOnDemand="Automatic", it is working as required.
Please help me out
Shital
Hi Shital,
LoadOnDemand is very important property of grid. Different settings of this property change the grid behavior drastically. So, we first need to understand difference between different LoadOnDemand modes. Check following link for detail.
http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR3.5/html/Infragistics35.WebUI.UltraWebGrid.v8.2~Infragistics.WebUI.UltraWebGrid.UltraGridLayout~LoadOnDemand.html
As per my understanding it means that
(1) Automatic mode:
Gird bound with all the rows in the data source. Grid contains all the rows of first level initially. As rows get expanded child rows are getting added. You can refer any child row of entire grid once it is expanded. Rows expand needs full post back.
(2) XML mode:
Grid bound with first level rows of first page only at initial load. The rows count of top level rows could be specified in RowsRange property of DisplayLayout.
Grid doesn’t contain any child row until child rows demanded by expanding any row. Rows expand will happen by AJAX.
Persistence of rows and child rows depends upon different modes of XML LoadOnDemand which could be set using XmlLoadOnDemandType. Refer this link for further detail.
http://help.infragistics.com/Help/NetAdvantage/NET/2008.2/CLR3.5/html/Infragistics35.WebUI.UltraWebGrid.v8.2~Infragistics.WebUI.UltraWebGrid.XmlLoadOnDemandType.html
You can easily test this using these lines of code.
protected void Button1_Click(object sender, EventArgs e)
{
string childRows = String.Empty;
foreach (UltraGridRow row in UG1.Rows)
childRows += row.Rows.Count + ",";
}
Label1.Text = childRows;
Execute above code with different setting of Automatic mode and XML mode. For XML mode set RowsRange and XmlLoadOnDemandType Also (Ex. RowsRange="5", XmlLoadOnDemandType="Accumulative").
But if you still want to use specific XML mode and you want to access child rows then you need to consult original Data source for getting child rows.
You can search actual DataRow from datatable using selected Row's data key and then you can find child rows of that row.
I hope this will help you.
Hello Shital,
LoadOnDemand = Xml mode is designed to bring minimum of the HTML every time there is a full post back. So the expanded rows are collapsed automatically.
You might want to try to set the XmlLoadOnDemandType=Accumulative.
Hope this helps.