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
In this case I suggest you to use DataView in order to extract needed data from your second band. Also I assume that formatting of your rows is made in InitializeRow event of UltraGrid, so you could assign same delegate for InitializeRow even of your second grid in order to apply same formatting to the corresponding rows. I’ve implemented this suggestion in a small sample, please run it and let me know if this is what you are looking for.
Please let me know if you have any further questions.
...forgot to mention. i did try formatting with the initializerow event, it did not do what i hoped. not all the formatting of the main grid was done with initializerow event.
most of it was done in other methods, row colors were constantly changing, columns were hidden, filterable, font was changed.
i was hoping to capture those attributes.
have a good weekend
Hello,
Save/Load layout will works only if both of your grid have same data schema and data, in your case in your second grid first band is missing. So what you could do in your case is to create layout of the second grid, based on the band 1 of the first grid. You could use code like:
ultraGrid1.DisplayLayout.CopyFrom(ultraGridWatch.DisplayLayout .Bands[0].Layout , PropertyCategories.All );
Also if the appearance was managed on a row or cell level then you should re-evaluate them for the second grid. In this case my suggestion is to subscribe second grid for same delegate which firs grid uses.
I hope that this will helps you.
i see where you're going with it but it's not working for me. the 2ndary grid is on a seperate non modal form. So that form class has an UltraGridLayout (_ul) object which is being passed in from the parent form via constructor.
so when i bind the grid...i set the datasource, After which if i take the _ul object for my layout. using CopyFrom, or just setting the layout.
parentgrid: ultraGridWatch.DisplayLayout.Bands[1].Layout;
i try to copy that layout and set as my secondary grid.
ultraGridUnPriced.DataSource = unpricedRows; ultraGridUnPriced.DataBind(); if (_ul != null) ultraGridUnPriced.DisplayLayout.CopyFrom(_ul,PropertyCategories.All);
what am i missing? is there something else i should be providing?
thank you again for your help
to comment on the other stmt, all of our formatting of the grid happens via timer like a refresh. we don't do it in the initializerow event. Sounds like this would be a much better strategy then i could subscribe to it from other grids.
this is an old and fairly complex app that's been handed down a few times. i'm trying to provide additional functionality without muddy'ing this app any further.
As far as I understand from your latest post you were able to resolve this.
Please do not hesitate to contact with us if you have any further Infragistics related issues.
Thank you Hristo, i am all set here.
Hello,
I am just checking about the progress of this issue. Let me know If you need my further assistance on this matter?
Thank you for using Infragistics Components.
Thank you for getting back to me. I really hope that my latest suggestion will works for you. Please take your time to test my latest sample and let me know if there is anything further that I could do for you.
hi Hristo, i haven't been here the last day or so and havent gotten the chance to finish.