hi,
i have an odd request. i have an app with a grid including (2 bands). this app refreshes the grid in the background and i want to take a subset of the rows from th grid and display them on another grid. hopefully including formatting from original grid.
i've tried a couple of different things with LINQ but not getting the desired result.
//first trying to get detail rows, 2nd band (band=1)
var allRows = from r in ultraGridWatch.Rows.Where (f=>f.Band.Index==1) select r;
//then from those, literally filter on ultragridrows for cells with a specific value. var unpriceRows= from r in allRows where r.Cells["LAST"].Value.ToString().Trim() == "" select r;
i do believe the first query works because when i run the 2nd query it doesn't complain about "LAST" column. (whereas, just querying the first band threw an exception for that column )
ideally i just want unpriceRows to be a formatted list of the rows i filtered. Then i can copy them and display in a seperate grid.
anyone have any idea on how to achieve this?
thanks in advance
Al
Hello ,
Rows collection returns a collection of the topmost level of rows in the grid. This collection will either contain all the rows in Band 0 or the top level of GroupBy rows (if GroupBy rows are being used.). In other words to get rows from the second band, you should go through row from the first band and then to reach its child bands. You could use code like:
List<UltraGridRow> unpriceRows = new List<UltraGridRow>();
foreach (UltraGridRow row in ultraGridWatch.Rows)
{
unpriceRows.AddRange(
row.ChildBands[0].Rows.Where(r => r.Cells["LAST"].Value.ToString().Trim() == "")
);
}
Also I think that it will be easiest and faster if you get your needed rows form the underlying data source. Can you please let me know what king of data source you are using.
I am waiting for your feedback.
thanks Hristo, the underlying datasource of the main grid is a DataTable. your recommendation does make sense but i was trying to pull directly from the grid in hopes that i could persist the formatting of those rows to the 2nd grid.
is there a way to do with only the datasource? should i do a save/load layout between 1st and 2nd grids?
thank you