Custom bool filter and advanced filter questions

17 posts, 0 answers
  1. Giovanni
    Giovanni avatar
    37 posts
    Member since:
    Feb 2011

    Posted 05 Feb 2013 Link to this post

    Hello,
    I'm trying to setup a custom filter for boolean. Is it possible? For the other filter types I have no problem, but for boolean filter I can't set up my UI widget. This is my code for filter set up:

    filterable:
    {
    ui: function(element)
    {
    element.kendoDropDownList({
    dataSource: new kendo.data.DataSource({
    data: [
    {text:"True", value:true},
    {text:"False", value:false}
    ]}),
    dataTextField: "text",
    dataValueField: "value"
    });
    }
    }

    I would like to have a dropdown with the two value, "True" or "False". I don't have any errors, but the custom filter is not displayed.
    Moreover I have also another couple of questions:

    1) Is it possible to remove the "Or" logical operator from the dropdown? I would like to have only the "And" operator.
    2) Is it possible to remove the "extra" field from only one filter? If I setup "extra:true" all the filters have the extra options.

    Thanks
  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2883 posts

    Posted 07 Feb 2013 Link to this post

    Hello Giovanni,

    Thank you for getting in touch with us. Straight to your questions:

    I'm trying to setup a custom filter for boolean. Is it possible?
    This is not possible - by design boolean fields does not support filter customization (you can only change the labels of radio buttons). The main obstacle is that this filter menu uses checked binding while the other filter inputs use value binding. Checked binding works with check boxes/radio buttons only, the DropDownList is a select element.

    1) Is it possible to remove the "Or" logical operator from the dropdown? I would like to have only the "And" operator
    I am afraid that this is currently not possible through the configuration options. The only possible solution is to find the corresponding DropDownList widget and remote the "Or" option from its DataSource.

    2) Is it possible to remove the "extra" field from only one filter? If I setup "extra:true" all the filters have the extra options.
    Yes, you can set extra: false to a single column only. 
    { field: "name", filterable: { extra: false } },

    Regards,
    Alexander Valchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Alexander
    Alexander avatar
    19 posts
    Member since:
    Jun 2012

    Posted 04 Apr 2013 Link to this post

    " (you can only change the labels of radio buttons)."

    Is there documentation on how to do this? I'm trying to get the filter radio button labels to match the template strings applied to my boolean field.
  4. Nikolajs
    Nikolajs avatar
    2 posts
    Member since:
    Jan 2013

    Posted 05 Apr 2013 Link to this post

    @(Html.Kendo().Grid<EntityName>()
            .Name("GridName")
            .Columns(columns =>
            {
                columns.Bound(c => c.HasEditingRights);
            })
            .Filterable(filterable =>filterable.Messages(m=>m.IsFalse("No"))
               .Messages(m=>m.IsTrue("Yes")))
    )
    For bool filter's labels try this approach.
  5. Alexander
    Alexander avatar
    19 posts
    Member since:
    Jun 2012

    Posted 05 Apr 2013 Link to this post

    Thanks Nikolajs, I was looking for a way to do it client-side with Kendo UI Web. Your response helped me though! In case anyone else wonders about this, here's how to do it:

    $().kendoGrid({
    columns: [ { field: "FieldName", title: "FieldTitle", template: kendo.template('#= FieldName ? "trueString" : "falseString" #'), filterable: { messages: { isTrue: "trueString", isFalse: "falseString" } } }
    ]
    });
  6. Stefan
    Stefan avatar
    8 posts
    Member since:
    Aug 2011

    Posted 15 Oct 2015 in reply to Alexander Valchev Link to this post

    Hi Alexander,

    Just wondering if it is now possible to create a custom filter for boolean? If not, is there a different way to filter nullable booleans? The filter currently defaults to the "is true / is false", but no option for neither (null).

    Thanks,
    Stefan.

  7. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2883 posts

    Posted 19 Oct 2015 Link to this post

    Hi Stefan,

    Null filtering is not supported at present. This is a top feature request at Kendo UI feedback portal and will be implemented in Q1 2016 release which is due to be published in January 2016.

    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  8. Stefan
    Stefan avatar
    8 posts
    Member since:
    Aug 2011

    Posted 19 Oct 2015 in reply to Alexander Valchev Link to this post

    Awesome, looking forward to it!

    Thanks.

  9. Skip
    Skip avatar
    4 posts
    Member since:
    Aug 2011

    Posted 26 Jan 2016 in reply to Alexander Valchev Link to this post

    It certainly would be helpful if the API documentation mentioned this.
  10. Skip
    Skip avatar
    4 posts
    Member since:
    Aug 2011

    Posted 26 Jan 2016 in reply to Skip Link to this post

    (that's in reference to the earlier comment that filter customization is not supported on Boolean columns --- I clicked "reply" to that message, but it still put my message at the end)
  11. Skip
    Skip avatar
    4 posts
    Member since:
    Aug 2011

    Posted 26 Jan 2016 in reply to Skip Link to this post

    jeez ... apparently the link embedding doesn't work either .... I'm referring to this documentation:
    http://docs.telerik.com/KENDO-UI/api/javascript/ui/grid#configuration-columns.filterable.ui
  12. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2883 posts

    Posted 28 Jan 2016 Link to this post

    Hello Skip,

    New operators are documented in filterable.operators.[string/number/date/enum] section

    • http://docs.telerik.com/KENDO-UI/api/javascript/ui/grid#configuration-filterable.operators.string.isnull
    • http://docs.telerik.com/KENDO-UI/api/javascript/ui/grid#configuration-filterable.operators.string.isnotnull
    • http://docs.telerik.com/KENDO-UI/api/javascript/ui/grid#configuration-filterable.operators.string.isempty
    • http://docs.telerik.com/KENDO-UI/api/javascript/ui/grid#configuration-filterable.operators.string.isnotempty
    • //etc.


    Regards,
    Alexander Valchev
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  13. Skip
    Skip avatar
    4 posts
    Member since:
    Aug 2011

    Posted 28 Jan 2016 in reply to Alexander Valchev Link to this post

    Hi Alexander,

    My comment was in regard to your response on Feb 7 2013:

    I'm trying to setup a custom filter for boolean. Is it possible?
    This is not possible - by design boolean fields does not support filter customization

     

    When creating a custom filter, you would be utilizing the UI property of the column's filterable setting, as documented here:
    http://docs.telerik.com/KENDO-UI/api/javascript/ui/grid#configuration-columns.filterable.ui

    That documentation makes no mention of the fact that creating a custom filter for a Boolean column is not possible.
    When you attempt to do so, it simply does not work.  
    There is no error, it simply does not work.

    That's why I think it would be helpful if the documentation of the UI property mentioned this.

  14. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1777 posts

    Posted 01 Feb 2016 Link to this post

    Hello Skip,

     

    Thank you for your feedback, indeed we will update the article. 

     

    Regards,
    Boyan Dimitrov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  15. Scott Waye
    Scott Waye avatar
    122 posts
    Member since:
    Nov 2009

    Posted 25 Feb 2016 in reply to Boyan Dimitrov Link to this post

    If you get to the bottom here and are disappointed, you can vote for this feature: http://kendoui-feedback.telerik.com/forums/127393-telerik-kendo-ui-feedback/suggestions/12477711-bool
  16. Konrad
    Konrad avatar
    6 posts
    Member since:
    May 2011

    Posted 4 days and 9 hours ago Link to this post

    Hello.

    Can you combine the "isempty" and the "isnull" filter in a way that offers just 1 filter to the user in the grid header? As a user, I do not want to set up 2 filters linked with OR to simply list all entries, that LOOK empty, which can be undefined, null or an empty string. We need a filter like "looksempty" which performs both, the "isempty" and the "isnull" filtering...

    Explanation: Some database null-values are not transmitted with JSON, so they are undefined in the datasource. With a template we display them as an empty string, but this does not affect the filtering, which is performed on the datasource. Filtering those undefined values cannot be performed with "isempty". But filtering empty strings cannot be performed with the "isnull" filter...

    In .Net there is something like String.IsNullOrEmpty(), which is great. Something like that would be needed in the filtering here as well.

  17. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1777 posts

    Posted 11 hours ago Link to this post

    Hello,

    I am afraid  that adding a custom filter to the Grid's filter menu is currently not supported If you consider that it would be a useful addition to Kendo UI you could post it as a suggestion in our Kendo User Voice portal. If it gets popular among the community we will consider to implement it in future releases of Kendo UI.

    Regarding the current scenario, since a custom client side filtering is required, I would suggest you to implement it outside of the Grid and manually filter the dataSource data with the filter method. This approach allows to set a filter expression containing both operators with "OR" logic. 

    Regards,

    Boyan Dimitrov

    Telerik by Progress

    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top