Grid Filtering on null DropDownList Item

2 posts, 0 answers
  1. Don
    Don avatar
    4 posts
    Member since:
    Oct 2014

    Posted 05 Dec 2014 Link to this post

    I am trying to filter the Grid based on what the user types.  One of my fields is a drop down list and if the foreignKey ID is null the filter breaks because it cannot get the value.  

    The field is Gender.  Is there a way to first check if Gender_Id is null before I check Gender_Types.Gender?  Because if Gender_Id is null then so is Gender_Types.

    Here is my code:

    // Filter the Grid as a user types
        $("#Search").on("keyup click input", function () {
            grid = $("#Grid").data("kendoGrid");
            var searchFilter = { logic: "and", filters: [] };

            if (this.value.length > 0) {
                var search = this.value.trim();
                var search_array = search.split(" ");
                for (var i = 0; i < search_array.length; i++) {
                    var filter = { logic: "or", filters: [] };

                    filter.filters.push({ field: "Full_Name", operator: "contains", value: search_array[i] });
                    filter.filters.push({ field: "Gender_Types.Gender", operator: "contains", value: search_array[i] });


                grid.dataSource.query({ filter: searchFilter });

                // When done filtering select page one otherwise no page is selected

            } else {
                grid.dataSource.query({ filter: searchFilter });

                // When done filtering select page one otherwise no page is selected

  2. Petur Subev
    Petur Subev avatar
    1882 posts

    Posted 09 Dec 2014 Link to this post

    Hello Donald,

    Filtering/grouping/editing etc. on a nested field is not really supported - we strongly recommend to flatten the data before showing it into the Grid.

    What kind of dataSource operations do you use? Do you use serverFiltering set to true or to false?

    In case you are using server side operation you can implement custom filtering and handle that null checking logic manually.

    If using client side operations you can try to filter with a custom operator:

    Kind Regards,
    Petur Subev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top