Grid ForeignKey Column Filter Operators

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