Hi ,
We are using ultrawingrid to display the hierarchical level of data and i need the top level filter to do in all the child level filter also.Pls help me on this.
Note : All the Levels are having the same no.of columns and same name
Hi,
There's no built-in way to filter across all bands automatically. What you could do is trap for the grid's AfterRowFilterChanged event for the first band and then copy the same filter criteria into all of the other bands.
You will probably also want to handle the population of the filter dropdown list, since it only shows unique values that exist in the current band. This is slightly trickier. You would either have to loop through every row in all bands to build your own unique list (which could be very inefficient depending on the number of rows in your grid), or build the list from a set of known values.
I have attached a small sample project here which demonstrates this technique. Please let me know if you have any questions.
Hi Mike,
Thanks for the reply.I added the code in AfterRowFilterChanged() for looping all the band and setting filter for selected attribute .if we filter the value which is there in second level it is hiding all the level.
Q1:
if (e.Column.Band.Index == 0) { UltraGrid grid = (UltraGrid)sender; UltraGridLayout layout = grid.DisplayLayout; UltraGridBand rootBand = layout.Bands[0];
// Loop through all of the other bands and copy the filter conditions. for (int i = 1; i < layout.Bands.Count; i++) { UltraGridBand band = layout.Bands[i];
ColumnFilter rootBandColumnFilter = rootBand.ColumnFilters[e.Column.Key];
// We are making the assumption here that a column exists in each band that // has the same key as the column in the root band. ColumnFilter childBandColumnFilter = band.ColumnFilters[e.Column.Key];
// Clear the child band's column filters. childBandColumnFilter.ClearFilterConditions();
// Copy the root band's column filters into the child band foreach (FilterCondition filterCondition in rootBandColumnFilter.FilterConditions) { childBandColumnFilter.FilterConditions.Add((FilterCondition)filterCondition.Clone()); } } }
Q2:
Earlier we were getting header for all the level.after we added the below code all the header it is coming on top.How can we display single header with doing filter on all the level
ultraGrid1.DisplayLayout.Override.HeaderPlacement = Infragistics.Win.UltraWinGrid.HeaderPlacement.FixedOnTop;
Q1)
I'm not sure I understand what you are saying here. In my sample, I only showed one FilterRow for the band. If you show the FilterRow for other bands, then you would have to modify the AfterRowFilterChanged to take the filters from the current band (and not always band 0 like I am doing) and apply the filters to all of the other bands.
Q2) I'm not sure what you are asking here, either. In my sample, there is only one filter row and it is already fixed at the top of the grid. I did this by setting the FilterUIType only on the root band. If you are getting different behavior, then you must be setting something differently than in my sample. I'm not sure what that would be, though. If you can post a small sample project demonstrating the behavior you are getting, I would be happy to take a look.
I attached here the sample project.Pls let me know ,what is missing there?
Thanks,
selvi
Hi Selvi,
The problem with the column headers is very easy to fix. Just hide the column headers on all but the first band. You could do this in InitializeLayout:
foreach (UltraGridBand band in layout.Bands) { if (band.Index == 0) band.ColHeadersVisible = true; else band.ColHeadersVisible = false; }
Thank you.It works.Now i am getting single header .
I have attached the sample project for the single Filter for hirerarchical display.Here i got all the field value to filter but when doing filter it is filtering only first band and we are not able to filter other than the first level .Please share if you have any idea on this.
I ran your sample and applied a filter and it's applying to all of the bands. For example, if I drop down the list for the Name column and select "Real Property", all of the rows are hidden except the one row in the root band whose name is "Real" property.
I think there might be some confusion here about what you actually want in terms of filtering, though. Because the data you have in this sample app doesn't make a lot of sense to filter on all bands. You don't really have a lot of values that are the same across bands, so any time you filter on any value that exists in a child band, all of your parent rows which do not match the filter) will be filtered out and you won't see any child rows because the parent row is filtered out and you cannot show a child row with no parent.
So It's not entirely clear to me what you want to happen in that case.
Do you really want to filter to apply across all bands? Or do you want to filter on the lowest-level band and have parent rows with no children hidden? Or something else?
Thanks .Yes we want to filter for all the band .In this sample project, we have filter column "CustomerID" and we are having the row on third and fourth band also.if we filtered based on CustomerID it is not displaying anything. I have attached the screenshots for that.Pls let me know if we want to filter for all the band,what should be change here?
Okay, I looked at your screen shot. This is exactly what I was trying to explain in my previous post. If you filter by "CustomerID" like you are doing here, than there are no rows in the root band that match this value, so all of the root rows are filtered out. Since the child row cannot be displayed without it's parent, no rows are visible. But that is the behavior you asked for here - to filter on ALL bands.
It seems to me that filtering on all bands is not really what you want. You apparently want to filter only on the last band. Or else maybe you want the filter to somehow figure out which bands to filter on based on the value.
Both of these would be extremely tricky and much more complicated than the sample I created here.
Filtering on the last band would be tough because the FilterRow you are displaying is displaying for the root band. You would have to find a way to make the filters display, but not actually filter anything. Then copy those filters to the last band. Then, you would have to filter on the root and child bands so that rows with no children are filtered out. The first two parts are pretty easy, but that last one could be tough.
If you want context-sensitive filtering where the grid somehow determines which band to filter based on what the user selects from the list, then I'm not sure that's even possible. I suppose when you populate the filter dropdown list, you could add some data to the item that indicates which band it came from and then you could implement your own custom FilterCondition from there. But this would be very complex and I'm not sure if it's even logically possible.
Do you need any further assistance with this? Have you determined the behavior you want here? If so, then I might be able to help you choose how best to achieve it.