This is a migrated thread and some comments may be shown as answers.

How to apply a style on filtered rows ?

8 Answers 55 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ludovic
Top achievements
Rank 1
Ludovic asked on 20 Nov 2015, 01:52 PM

Hi,

 

I use a RadGridView and I need to apply a style to the filtered elements. Currently, they disappear off course. Is there a way to set a property "visible" and a forecolor specific ? Like this :

http://image.noelshack.com/fichiers/2015/47/1448027537-2217-noelpush.png

 

Thanks !

 

Regards.

8 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 24 Nov 2015, 02:10 PM
Hi Ludovic,

In general, irrelevant to whether you have filtered the Items of RadGridView or not, you can benefit from the  RowStyleSelector / CellStyleSelector functionality that the control supports. You can also check out the StyleSelectors section of RadGridView's online demos or their WPF equivalents.

Let me know should you need further assistance.

Best Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ludovic
Top achievements
Rank 1
answered on 24 Nov 2015, 03:09 PM

Hi Stefan,

 

Thank you for your answer but I don't understand. I tried to apply the RowStyleSelector with the red/yellow backgrounds and I can reproduce the example in my project.

But the style isn't applied to the filtered rows. I created a GridViewRowStyle like this for check :

<Style x:Key="GridViewRowStyle" TargetType="telerik:GridViewRow">
    <Setter Property="Visibility" Value="{Binding RowVisibility}" />
</Style>

And in my class StadiumCapacityStyle, the method SelectStyle is called when I use a filter, ok. The issue is that I can see only the rows with a RowVisibility property equals to Visibility.Visible and which corresponds to the criteria of my filter. The filtered rows which are hidden can't receive the style BigStadiumStyle or SmallStadiumStyle. Do you see what I mean ? 

 

Regards.

0
Ludovic
Top achievements
Rank 1
answered on 25 Nov 2015, 09:23 AM

Hi,

 

I found a solution. I subscribed to the "Filtered" event and I call the method this.RadGridView.FilterDescriptors.Clear();

I can retrieve the filter criterias in my viewmodel then manually apply a style (with RowStyleSelector) to my items. Thanks for your help !

 

Regards.

0
Ludovic
Top achievements
Rank 1
answered on 25 Nov 2015, 02:49 PM
However, I must admit that recode the filtering system is a bit tedious, because I need currently browse through the items one by one and see if they match the criteria. If there exists a method that would allow me to simply change the rows filtered "Hidden" instead of "Collapsed", i'll take it.

Regards.
0
Stefan
Telerik team
answered on 27 Nov 2015, 12:28 PM
Hi Ludovic,

In general, modifying the Visibility of the visual elements of the control is something that we do not recommend. RadGridView is a virtualized component and using it in such way can lead to unpredictable results. You can take a look at the UI Virtualization topic for more information.

Can you please share some details on your requirements and why do you need to apply a style to an element that is not visible?

Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ludovic
Top achievements
Rank 1
answered on 27 Nov 2015, 12:58 PM

Hi Stefan,

 

In an other thread, I explained that I'm creating a control with a RadGridView which has a "zoom", like this : 

http://image.noelshack.com/fichiers/2015/47/1447859201-5988-noelpush.png

And when I use a filter, several rows disappear and the spacing between the rows becomes wrong (the chronology is broken, actually). So I need that the rows stay visible, because the height of every cell is important, but the text must be hidden for that the user sees only the rows which correspond to the criterias.

 

So now in my code, I continue to use the interface of the filters provided by the RadGridView (the little windows with the field filters and the distinct filters), but I prevent the control to filtering the data, and I call in place an algorithm which applies to each value of my collection an opacity of 0 or 1. This was not very practical to establish but it works...

Sorry for my english.

 

Regards.

0
Ludovic
Top achievements
Rank 1
answered on 27 Nov 2015, 01:03 PM

This is an illustration :

http://image.noelshack.com/fichiers/2015/48/1448629402-8935-noelpush.png

0
Stefan
Telerik team
answered on 02 Dec 2015, 09:36 AM
Hi Ludovic,

As this requirement is a little bit specific, I am afraid that there is no out-of-the-box approach that I can suggest you for achieving it. A possible solution would be to either use the logic you have already implemented, or try using a RowStyleSelector and set the Foreground of a given row to transparent("#00000000").

Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Ludovic
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Ludovic
Top achievements
Rank 1
Ludovic
Top achievements
Rank 1
Share this question
or