Showing column menu with option to hide columns in one column while showing filters in other columns

2 Answers 110 Views
Grid
Vijai
Top achievements
Rank 1
Vijai asked on 21 May 2021, 12:10 PM

I currently have 8 columns in the grid and each column has the filter option enabled. I want to add more columns and provide the option to hide columns to the user.

I want to retain the filter option in all columns as it is most often used by the user, but provide the 'hide column' option ONLY in the last column, as in the attached mockup. 

Is this possible? If so, how?

Is it like hide columnmenu in all columns except the last one and setting columns.filterable = true for all other columns?

Sorry for not adding any code, I am not a dev!

2 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 26 May 2021, 07:46 AM

Hi Vijai,

This can not be set with the current Grid API, however, it can be achieved with custom logic in the columnMenuInit event handler:

For example:

columnMenuInit: function(e) {
          if (e.field !== "city") { //different than the last column
            var filterItem =  $(e.container).find(".k-first");
            var separator = $(e.container).find(".k-menu-separator");
            filterItem.hide();
            separator.hide();
          }
        }

Here is a Dojo demo I prepared demonstrating the above:

Let me know if you have any questions.

Regards,
Nikolay
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/.

Vijai
Top achievements
Rank 1
commented on 26 May 2021, 11:48 AM

Thanks Nikolay. Is there a way to show the column menu only in the last column i.e. the three dots only in the last column but show the Filter icon in other columns. I mean in your dojo, the user will need to click the three dots and then select the filter. Is there a way to show the filter icon directly while only showing the three dots in the last column?
0
Nikolay
Telerik team
answered on 31 May 2021, 08:15 AM

Hi Vijai,

To achieve this I recommend following the approach shown in the next article:

https://docs.telerik.com/kendo-ui/knowledge-base/grid-conditional-columnMenu

I added logic to update the icons on the columns with no column menu in the dataBound event handler:

https://dojo.telerik.com/ItEMetaZ

Let me know if you have any questions.

 

Vijai
Top achievements
Rank 1
commented on 31 May 2021, 11:35 AM

Awesome! Thanks for your help Nikolay!
Nikolay
Telerik team
commented on 03 Jun 2021, 06:45 AM

Hi Vijai,

You are most welcome. I am glad to hear this is what you were looking for.

Regards,

Nikolay

Tags
Grid
Asked by
Vijai
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or