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

Grid ForeignKey Column Filter Operators

6 Answers 222 Views
This is a migrated thread and some comments may be shown as answers.
Rick
Top achievements
Rank 1
Rick asked on 04 Sep 2013, 06:33 PM
I noticed that the filter for a foreignkey column is a dropdown and uses the "is equal" or "is not equal" operators.  Is it possible to have the foreignkey column filter to have the option of contains and/or use a combobox?

example column:  c.ForeignKey(p => p.LocationID, (SelectList)ViewData["LocationID_Data"]) .Title("Location").Width(250);

Thanks

6 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 06 Sep 2013, 09:12 AM
Hi Rick,

I am afraid that what you would like to achieve is not supported.

ForeignKey columns support only two filter operators - "Is equal to" and "Is not equal to". Kendo UI provides ability to remove one of them or modify the text displayed to the user. The syntax is:
.Filterable(
  filterable => filterable.Operators(
    operators=>operators.ForEnums(
      enums=>enums.Clear().IsEqualTo("corresponds to")
    )
  )
)


Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Rick
Top achievements
Rank 1
answered on 11 Sep 2013, 07:49 PM
Why is this? I want the "contains" operator. The foreignkey column has so much potential but seems to just fall short of anything useful.
0
Petur Subev
Telerik team
answered on 13 Sep 2013, 12:56 PM
Hello Rick,

After all the ForeignKey column is  bound to a numeric field of your model. Which means that you are not actually able to filter with ComboBox because ComboBox can have free value from the user when no item from the collection is selected and this is not valid for the dataSource filtering and how it works..

If you want to have more flexibility you can create regular bound column, specify its template, its editor template and its filter menu UI so it does the same job as a regular ForeignKey column. All those settings are demonstrated separately in the documentation / demos.

http://docs.kendoui.com/api/web/grid#configuration-columns.template
http://docs.kendoui.com/api/web/grid#configuration-columns.editor
http://docs.kendoui.com/api/web/grid#configuration-columns.filterable.ui

http://demos.kendoui.com/web/grid/editing-custom.html
http://demos.kendoui.com/web/grid/filter-menu-customization.html


Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Sergio
Top achievements
Rank 1
answered on 28 Feb 2018, 05:04 PM
thanks for the support, it works perfectly.
0
Craig
Top achievements
Rank 1
answered on 08 Aug 2018, 06:15 PM

Would you mind providing a sample C# VS2017 project that demonstrates how to combine all of these techniques into one ?

Thank you !

0
Stefan
Telerik team
answered on 10 Aug 2018, 09:25 AM
Hello, Craig,

As this is an old thread and some of the functionalities had changed, please share with us the use case and the desired end result.

This will help us provide specific information and example covering the real scenario.

This is how the ForeignKey column filter is working currently:

https://demos.telerik.com/aspnet-mvc/grid/foreignkeycolumn

This is the C# approach with the customization:

https://demos.telerik.com/aspnet-mvc/grid/filter-menu-customization

Regards,
Stefan
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
Rick
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Rick
Top achievements
Rank 1
Petur Subev
Telerik team
Sergio
Top achievements
Rank 1
Craig
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or