Grid ForeignKey Column Filter Operators

7 posts, 0 answers
  1. Rick
    Rick avatar
    2 posts
    Member since:
    Jan 2013

    Posted 04 Sep 2013 Link to this post

    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
  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2890 posts

    Posted 06 Sep 2013 Link to this post

    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!
  3. Rick
    Rick avatar
    2 posts
    Member since:
    Jan 2013

    Posted 11 Sep 2013 Link to this post

    Why is this? I want the "contains" operator. The foreignkey column has so much potential but seems to just fall short of anything useful.
  4. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 13 Sep 2013 Link to this post

    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!
  5. Sergio
    Sergio avatar
    1 posts
    Member since:
    Jan 2018

    Posted 28 Feb in reply to Alexander Valchev Link to this post

    thanks for the support, it works perfectly.
  6. Craig
    Craig avatar
    4 posts
    Member since:
    Aug 2014

    Posted 08 Aug in reply to Petur Subev Link to this post

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

    Thank you !

  7. Stefan
    Admin
    Stefan avatar
    1931 posts

    Posted 10 Aug Link to this post

    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.
Back to Top