Unplanned
Last Updated: 21 Jul 2020 15:20 by ADMIN
syian
Created on: 06 Jul 2020 09:23
Category: Filter
Type: Feature Request
1
Kendo Filter - Search multiple datasource items with one field name

I implemented the filter you can find on the documentation page. Let's say that the filter consists of a few fields and three of them are:

  • "First Name",
  • "Second Name" and
  • "Last Name".

I want to have a filter named "Name" and be able to search all three items - instead of having three different filters. I have read the documentation but it does not seem to be any reference to it. I thought of something like the following might be possible:

fields: [
    logic: "or",
    { name: "firstName",  type: "string", label: "Name" },
    { name: "middleName", type: "string", label: "Name" },
    { name: "lastName",   type: "string", label: "Name" }
]

 

Any workaround would be much appreciated.

6 comments
ADMIN
Anton Mironov
Posted on: 21 Jul 2020 15:20

Hello, Syian,

In order to use a boolean field in the grouped filter widget try the implementation below:

The setting of a boolean field, in this case, could be set as follows:

 editorTemplate:categoryDropDownEditor },
              { name: "Discontinued", type: "boolean" }

I hope this information helps.

Greetings,
Anton Mironov
Progress Telerik

syian
Posted on: 16 Jul 2020 12:33

Hi Anton, 

thank you again for the help. 

I implemented the grouping in the editor template as you suggested. I only have one problem with the implementation. I am not sure how I should add the boolean fields into the container. In your solution you use the following:

          $('<input data-bind="value: value" name="' + options.field + '"/>')
            .appendTo(container)
            .kendoTextBox();

But how can I only have the field-dropdown and the value-dropdown without the third box? I tried something like this, which it did not work:

          $('<input data-bind="value: value" name="' + options.field + '"/>')
            .appendTo(container);

And then I thought I could try it with a checkbox but its value is always empty:

          $('<input type="checkbox" data-bind="value: value" name="' + options.field + '"/>')
            .appendTo(container);

The ideal would be to only have the two dropdowns without any additional box/checkbox - if not possible then a solution with the checkbox should be fine. 

 

Thank you!

Regards,

Syian


PS. How do you add a code block here?

ADMIN
Anton Mironov
Posted on: 14 Jul 2020 15:43

Hi, Syian,

In order to group fields in the filter widget, try to implement the grouping in the editor template. Here is an example(for your usage set the needed field and value):

Changing the filter widget logic could be achieved with the help of the mainLogic property:

 var filter =   $("#filter").kendoFilter({
            applyButton:true,
            mainLogic: "or",
            dataSource: dataSource,
            fields: [
              { name: "UnitPrice", type: "number", label: "Unit Price and Units In Stock", defaultValue: 1, editorTemplate: numeric },
              { name: "UnitsInStock", type: "number", label: "Unit Price and Units In Stock", defaultValue: 1, editorTemplate: numeric },
            ],
            change:function(e){
            }
          }).data("kendoFilter");
Let me know if I could help you with anything else.

 

Kind Regards,
Anton Mironov
Progress Telerik

syian
Posted on: 10 Jul 2020 08:23

Hi Anton,
I have an update regarding the first matter and the creation of a filter with more than one fields.

I managed to make it work - thanks again for the provided code, it really helped - with all 4 fields I wanted, but the only problem now is that I can not change the default logic ("and") of the filter. Is it possible to change the logic from "and" to "or"?
For example: field1 or field2 or field3 or field4
instead of: field1 and field2 and field3 and field4

Something like this for example:

add.logic = "or";

Regards, 

Syian

syian
Posted on: 09 Jul 2020 10:56

Hi Anton, 

Sadly, is not exactly what I am looking for - the problem with your solution is that both fields are displayed in the dropdown, which makes it a bit less user friendly. 

Anyways, thank you for the response and for moving the ticket.

I have one more question regarding the kendoFilter. I could not find any guidelines in the documentation, suggesting that the customization of the dropdown on the filter is possible. For example, the kendoDropDownList offers the option of having the list groupped in different categories: https://demos.telerik.com/kendo-ui/dropdownlist/grouping. Would that be possible on the dropdown of the kendoFilter? 

Thank you in advance.

ADMIN
Anton Mironov
Posted on: 08 Jul 2020 11:06

Hi, Syian,

Thank you for contacting Telerik Support. 

In order to create a filter by more than one field try to handle your own conditions programmatically.

    Here is an example of the implementation with two merged fields(you could add the secondary fields to the underlying filter model yourself). Here is a proof of concept example:

    Since this functionality is not available I transferred this task to the public feedback portal and voted on your behalf. Here is the new link:

    Let me know if further assistance is needed.

    Regards,
    Anton Mironov
    Progress Telerik

    Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
    Our thoughts here at Progress are with those affected by the outbreak.