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

Kendo jQuery Grid , Get text on dropdown filter

3 Answers 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Derian
Top achievements
Rank 1
Veteran
Derian asked on 31 Aug 2020, 04:58 PM

How can i get the text field of a dropdown in the column filter?

I have the following example : https://dojo.telerik.com/izUviSID/2

3 Answers, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 02 Sep 2020, 01:46 PM

Hi Derian,

The way the data is structured in the provided example is not exactly what the Grid expects to receive as input data. Actually, it is displaying correctly the data provided to its dataSource.

To implement the targeted functionality do display the corresponding text in the Grid's menu we can use the approach discussed in this forum thread. Using the discussed columns.filterable.itemTemplate configuration here is a Dojo that demonstrates the targeted functionality for the 'Brand' column. 

To implement the targeted functionality, there is the following definition for the 'Brand' column:

filterable:{
      multi:true,
      itemTemplate: function(e) {
           return "<label><input type='checkbox' name='" + e.field + "' value='#= data.brandId#'/>#= getBrand(brands, data.brandId)#</label><br>" 								           }
}

Where the getBrand function is defined as follows:

  function getBrand(arr, brand){
      var result; 
    		$.each(arr, function(index, elem){
          	if(elem.brandId == brand){
            		result = elem.name;
            } 
        })
      if(result == undefined) {
      		result = "Select all"
      };
      
      return result;
    }

I hope the provided example will help you implement the targeted functionality in your application. 

Regards,
Petar
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

0
Derian
Top achievements
Rank 1
Veteran
answered on 03 Sep 2020, 02:51 AM
Thank you so much Petar
0
Petar
Telerik team
answered on 04 Sep 2020, 11:35 AM

Hi Derian,

You are welcome! I am happy that the suggested approach has helped you implement the targeted functionality.

Regards,
Petar
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Grid
Asked by
Derian
Top achievements
Rank 1
Veteran
Answers by
Petar
Telerik team
Derian
Top achievements
Rank 1
Veteran
Share this question
or