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,
An UltraDataSource would be on good way to go. You can also bind the grid directly to a collection. To acheive a hierarchy, the objects in the collection just need to expose a public property (or properties) that return other collections.
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