Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
Hierarchical display in Ultrawingrid
posted

Hello, 

We are using collections as datasource to ultrawingrid. How to display data hierarchically in ultagrid for a collection based datasource. we could achive this by using dataset & datarelation. But need to achieve the same with non dataset based datasources.

Thanks, 

 

Parents
No Data
Reply
  • 1590
    posted

    Hi, 

    For example, you have the datasource like this: List of Customers and  List of Orders related with each Customer.

    You should create two bands in UltraDataSource according to this hierarchy.First band - should be parent. Second - child. You can do it in designer or dynamicly.

    Then You can populate your Grid like this:

                    foreach (Customer customer in Customers)
                    {
                        UltraDataRow row = dataSource.Rows.Add();
                        row["Name"] = customer.Name;
                        foreach (Order order in customer.Orders)
                        {
                            UltraDataRowsCollection childRows = row.GetChildRows("Band 1");
                            UltraDataRow childRow = childRows.Add();
                            childRow["OrderName"] = order.Name;
                            childRow["Status"] = order.Status;
                            childRow["OrderData"] = order.Data;                    
                        }

                     }

    grid.DataSource = dataSource;

     // dataSource - is UltraDataSource

Children