Gridview checkboxcolumn filtering issues

1 Answer 237 Views
GridView
Daniel
Top achievements
Rank 2
Iron
Iron
Daniel asked on 26 Oct 2022, 03:26 PM

Hi,

I’m a litte bit confused concerning checkboxes in the Telerik GridView. For this a made an example program to show the confusing point. It has to do with checkboxes, states and filtering.

I’ve a grid with a twoState checkbox and one with a threeState checkbox. The threeState one is doubled, one based on the nullable boolean and one with a typeconverter.

My goal is when I’ve a twostate checkbox column, to also have a twostate filter. When I let the code default, I get a threestate checkbox in the filter area. The third state is a filled box (Indeterminate). In my opinion it has no value because the filtering is treated like ‘I don’t care what the content is’ or simply ‘no filtering’. Ok.. I could live with that. The meaning of the Indeterminate status is the same as no filtering.

Now the first threestate one (bool?). when I start the application there is no checkbox in the filter area and it says ‘no filter’. If I want to filter I’ve to click explicitly on the filtericon, then the checkbox appears and I can click on it. The third state (Indeterminate) is like the first column. I see all the records. What I see as a problem is that I can’t filter on records who has Indeterminate (or null) as value. Thereby the meaning of the Indeterminate is not clear anymore. The filtering is treated like ‘no filter’ but in the records it means ‘there is no value’. Also I can’t get control on the appearance of the filterbox. Try playing with it by clicking on the checkbox and clicking ‘no filter’ in the contextMenu. Sometimes the filter checkbox disappears or its not clickable anymore. ??

The third checkbox column is one with a typeConverter behind it. At start of the application there is a checkbox in the filterarea and its stated as Indeterminate. I see all the records so it’s meaning should be the same as the first column – ‘no filtering’. Now when I start clicking on the filtercheckbox the meaning changes. Now it filters on Indeterminate. When I remove the filter through the contextMenu, the filterbox disappears. This is actually correct but it’s start state is not.

So, I’m pretty confused now.

Of course I’ve searched around on the internet and I found something interesting. In one the items on the Telerik forum I saw a possibility for breaking in on the filter checkbox appearance – it’s the ViewCellFormatting event. It looks like that when I’ve a twostate column, the filtercheckbox gets threestate and visaversa. Is this a bug??

In my example application I changed that (see code). A twoState column gets also a two state filtercheckbox by setting it explicitly. So please enable the eventhandler and run the program again.

Now I almost get what I would expect. The first column which is twostate, can only be filtered on 2 states. True or false. If one want to see all, remove the filter. Sounds logically.

The first threestate column (bool?) has no checkbox at start of the application. When I set filtering through the contextMenu, it appears and the meaning of Indeterminate is like ‘no filter’. If I remove the filter, the checkbox does not and the state is Indeterminate. ??

The second threestate (with a converter) reacts the same as without the eventhandler. It starts with a checkbox in the filter area which has the Indeterminate state, but I see all the records. After clicking it, it starts to filter it correctly. At removing the filter, the filterbox is empty.

As you can probably understand the current situation is not acceptable for us because of ambiguous meanings and inconsistency concerning the start situation and after working in the grid.

 What’s going on?? What is the intention of Telerik and where do I get confused??

 What I would like to have is in case of a two state column, a two state filtercheckbox and the working of the column with the converter except not with that starting state. At start the filterbox should be empty.

Please help me out of this.

1 Answer, 1 is accepted

Sort by
0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 28 Oct 2022, 12:43 PM

Hello Daniel,

I greatly appreciated the sample project and your time in writing such a detailed post.

The different behaviors which you observe are the results of the different settings of the columns: DataType, ThreeState, etc.

Let me start column by column. 

  • TwoStateCheckbox Column:  You are in the right direction. When you run the project, in this column filter area you will see three state checkboxes. The Indeterminate state will be used to clear the filter. As you mentioned in your post, similar to the"‘no filtering" option from the context menu. As you have already done, you can workaround this in ViewCellFormatting. Targeting the GridFilterCheckBoxCellElement element you can change its default ThreeState property value and set only a two-state option. To clear the filter you will need to use the context menu "No Filter" option.
  • ThreeStateCheckbox Column: Here your observation is correct. As the column has the ThreeState property set to true, the Indeterminate won't be anymore considered as a "no filter". By default when the ThreeState property is set to true the checkbox control in the filter cell will be collapsed when the filter operator is set to default. The approach here to filter the cells in the column is to use the filter context menu. However, I have tested it turns out that you can filter null values except by using the Custom option from the context menu. That is why I have logged it in our Feedback Portal where you can track its progress and subscribe to the item to get notified of its status change. I have updated your Telerik Points for bringing this behavior to our attention.
  • Painted Column: The scenario is a little bit different. As I specified above, when the ThreeState property is set to true, the filter checkbox will be collapsed. However, the object passed to the checkbox cells will be ToggleState enumeration. When using enumeration, the default filter operator is IsEqualTo. That is why when you run the example, you are seeing the filter cell checkbox. This is because when using enumeration you can't have a value different from the one specified in the enumeration. To change the default FilterOperator you can apply an empty FilterDescriptor to the FilterDescriptor property of the column which will have FilterOperator.None.

 

var check3 = new GridViewCheckBoxColumn("Painted");
check3.FilterDescriptor = new Telerik.WinControls.Data.FilterDescriptor() { Operator = Telerik.WinControls.Data.FilterOperator.None };
check3.DataType = typeof(Painted);
check3.DataTypeConverter = new PaintedToToggleStateConverter();
check3.ThreeState = true;
check3.Width = 120;

I hope that I was able to bring light to these GridViewCheckBoxColumns behaviors.

Regards,
Dinko | Tech Support Engineer
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Daniel
Top achievements
Rank 2
Iron
Iron
commented on 31 Oct 2022, 09:59 AM

Hi Dinko,

Thanks for your reaction. The solution you bring in for the start situation of the ‘painted’ column is not completely sufficient for us. At start of the application the filter icon is lightened up. The filter does react like expected so I think we’re close.

Is it possible to simulate a click on the ‘no filter’ contextmenu item other than calling radGridView1.FilterDescriptors.Clear()? (that neutralizes the workaround)?? The click creates the desired situation.

Can you help me with the filter icon??

Regards,

Daniel

Daniel
Top achievements
Rank 2
Iron
Iron
commented on 31 Oct 2022, 11:27 AM | edited

Dinko,

I also have issues with loading saved grid settings in case the column has a converter on it.

I extended the sample application with buttons for saving and loading grid settings. When I disable the painted column there are no issues. Can you have a look at this too??

regards,

Daniel

Dinko | Tech Support Engineer
Telerik team
commented on 01 Nov 2022, 02:03 PM

You are right that the filter icon stays as a filter is applied. In this case, you can use the approach demonstrated in the Set default filter operators in RadGridView help article. After applying the approach the filter icon is not highlighted however, the filter checkbox appears. You can hide it in the CreateCell event handler. As for the filter, the DataTypeConverter of the column needs to be manually set. You can do that in the constructor of the CustomGridFilterCheckBoxCellElement custom class. Check the updated project which demonstrated these workarounds.
Tags
GridView
Asked by
Daniel
Top achievements
Rank 2
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or