Hello,
I want to have multiple bands in ultrawingrid but all binded to one table. how can i achieve this kind of hierearchy?
Hello Rooma,
Maybe one possible way could be if you are using DataSet, DataTable and parent - child relation between two of the columns. For example:
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add("iIsn", typeof(int));
dt.Columns.Add("iPIsn", typeof(int));
dt.Columns.Add("Name", typeof(string));
DataRelation dr = new DataRelation("MY", dt.Columns["iIsn"], dt.Columns["iPIsn"],false);
ds.Relations.Add(dr);
Using this approach (with self related table) you could met endless loop of hierarchy, so if you want to prevent endless loop of hierachy, you could used MaxBandDepth property. By this way you could set the deep of your hierarchy or other possible approach could be if you hide your root node (for more details please take a look at the attached sample)
Let me know if you have any questions.
Regards
hi, i have a similar question but having multiple bands bound to one BindingList<>. all my data is coming from one bindinglist/source but my bands are essentially* groupings of the underlying data. so should i create seperate lists for each level that i want to have a band for? how do i tie it all together without the dataset and relation classes.
any help is appreciated.
thanks
Hi Al,
If you are binding the grid to a flat list, you could use the grid's OutlookGroupBy feature to create grouping without modifying your data source. It basically groups the data by the values of a particular field and creates GroupBy Rows under which the normal data rows appear.
Grouping is tightly tied to sorting. So to group by a particular field, you do something like this:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; layout.ViewStyleBand = ViewStyleBand.OutlookGroupBy; band.SortedColumns.Add("Int32 1", false, true); }
This displays the GroupByBox so that the user can changed the groupings by default. They just drag and drop columns to or from the GroupByBox at the top of the grid. If you want to turn that off, just add this;
layout.GroupByBox.Hidden = true;
Thanks Mike. that makes sense and i was able to do that. however my use case is slightly different. i have basically one flat/large table that logically holds many different product types. many fields are inapplicable to certain products etc. ...
what i have to do is have my grid show different columns depending on the product types. at the start i would not need child bands. i would have all bands at top level. One band for cars shows Make/Model another band at the same level shows boats group by city,state.
these 2 bands display different columns and drill down to different details.
am i making sense?
i think i need bands for this.
thanks Mike, i've never used the ultradatasource class before. if i copy my "entire data into it" will i maintain my realtime update capabilities? prob not a quick change for me but i'll start looking into it. Datatable for me at this point is not an option.
AL
Hi,Yes, you are correct. If you need to have different columns displayed for different types, then you would have to create a new data structure of some kind. There are a couple of approaches you could take.You would need to have a table of some sort for each type which essentially defined the columns for that type. You could use UltraDataSource for this and either populate the UltraDataSource all at once by copying your entire set of data into it, or else you could use the load-on-demand functionality of UltraDataSource so you define the structure up front but load the data as needed.Another option would be to try to build a DataSet with a single root table that lists the product types and then has multiple child bands (presumably one for each product type) that has only the columns you need for that type. Each parent row would essentially then have a child band for each type, but only the type that matches the parent row would display since there would not exist any child rows for the other types. This is something of an inefficient option, especially if you have a lot of product types. If you have 5 to 8 types, it would be okay, but if you have hundreds of types, this approach probably won't work.