DropDown filter on DataValueField

3 posts, 0 answers
  1. Rui
    Rui avatar
    17 posts
    Member since:
    Jun 2017

    Posted 06 Nov Link to this post

    Hi.
    I have this dropdown

    function SomeFilter(element) {

    $(element).attr('id', "SOmething");

    element.kendoDropDownList(
    {
      dataSource: {
        transport: {
          read:
          {
            type: "POST",
            url: "@Url.Action("SomeAction", "SomeController")"
          }
        }
      },
      filter: "contains",
      highlightFirst: true,
      delay: 300,
      optionLabel: "Select Something",
      dataTextField: "dataTextField",
      dataValueField: " dataValueField ",
      select: onSelect,
      dataBound: onDataBound,
      open: onOpen
    });
    }

    that is a filter in my grid

    columns.Bound(e => e.SomeValue).Title("SomeTitle").Width(85).Filterable(x => x.UI("SomeFilter").Extra(false));

    So far, so good. This all works fine. What I need to need is if there is a way to do the filtering on dataValueField instead of dataTextField.

  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    1324 posts

    Posted 08 Nov Link to this post

    Hi Rui,

    See this KB article, which shows how the DropDownList can be filtered by multiple fields. If in your scenario you need to filter only by the field set as dataValueField, you can set only that field (CustomerID in the linked example) in the dataSource's filters configuration:
    this.dataSource.filter({
      logic: "or",
      filters: [
        {
          field: "CustomerID",
          operator: "contains",
          value: filterValue
        }
      ]
    });


    Regards,
    Ivan Danchev
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Rui
    Rui avatar
    17 posts
    Member since:
    Jun 2017

    Posted 08 Nov in reply to Ivan Danchev Link to this post

    HI.
    Yep, I did just that. On filtering event, I have

    e.sender.dataSource.filter({

    field: e.sender.options.dataValueField,

    operator: e.filter.operator,

    value: e.filter.value.toUpperCase()

    });

     

    This works for all my filters.
    Tks.

Back to Top