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

Use ID behind text value of column in grid as filter

5 Answers 1221 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Roland
Top achievements
Rank 1
Roland asked on 01 Aug 2018, 01:17 PM

Hello Telerik,

I'm currently trying to get some columns in a KendoUI Grid to display a value OTHER than the value I want to pass in the "read" function to use in filtering the servery side query.  Right now all the other columns are using the actual displayed value to pass back to the filtering query on the backend.  So we're frequently using strings like "John Doe, Jane Doe" instead of a lstUserIDs "1,2" because we can't seem to get filtering functions to pass the id values instead of display values.  Here's a sample of the actual case in question.  I wasn't able to determine from the serverside demo in the docs how this might be accomplished, or even if it could.  

With the column configured as below, I end up with an error "VM8499:3 Uncaught ReferenceError: asset_class_nm is not defined".  Changing the inner field to "asset_class_nm" works, but then I again have a text list of the names instead of the list of internal bigint IDs that I'd like.  Thanks!

,{         
                    field: "asset_class_nm",
                    title: "Asset Class",
                    attributes: {
                        style: "text-align: left;"
                    },
                    filterable: {
                        dataSource: {
                                transport: {
                                    read: {
                                        url: "srv_get_asset_classes.cfm",
                                        dataType:"json",
                                        data: {
                                            field: "asset_class_id"
                                        }
                                    }
                                }
                        },
                        multi: true
                    }
                }

5 Answers, 1 is accepted

Sort by
0
Accepted
Alex Hajigeorgieva
Telerik team
answered on 03 Aug 2018, 09:03 AM
Hello, Roland,

The Kendo UI Grid with multi check filtering has an itemTemplate that can be used to pass a different value as the filter value, for example:

itemTemplate:function(e) {
    return "<div><label><input type='checkbox' name='" + e.field + "' value='#= data.ProductID #'/></label><span>#= data.ProductName|| data.all #</span></div>"
},

Using an itemTemplate as above results in a filter as pictured below - the filter field is still the same as the bound column field - ProductName but the value is the ProductID:




I hope this is what you want to achieve, please correct me in case I have misunderstood.

Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Roland
Top achievements
Rank 1
answered on 03 Aug 2018, 11:16 AM

Thanks, Alex.

This is exactly what I was looking for, and I was actually coming here to respond to the post and give the exact information you just did.  I was working with another developer yesterday and we figured this out.  Thank you very much for letting us know this is correct!

0
Alex Hajigeorgieva
Telerik team
answered on 06 Aug 2018, 12:30 PM
Hello, Roland,

I am pleased to hear that you have found your way around the documentation, it is an ongoing effort to improve its structure and content and any feedback you may wish to share is most welcome.

In case, you have further questions, please feel free to get back to me.

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
samk
Top achievements
Rank 1
answered on 06 Nov 2018, 06:47 PM
Is itemTemplate available when multi check is false(Or for simple drop down)? 
0
Alex Hajigeorgieva
Telerik team
answered on 08 Nov 2018, 12:56 PM
Hi,

The Kendo UI Grid supports custom filterable UI in the FilterMenu with the help of the columns.filterable.ui property:

API Reference: https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/columns.filterable.ui 
Official demo: https://demos.telerik.com/kendo-ui/grid/filter-menu-customization

Kind Regards,
Alex Hajigeorgieva
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Roland
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Roland
Top achievements
Rank 1
samk
Top achievements
Rank 1
Share this question
or