change default date filter & reduce filter options

3 posts, 1 answers
  1. Muhammad
    Muhammad avatar
    12 posts
    Member since:
    Aug 2015

    Posted 23 Nov 2017 Link to this post

    Hi,

    I am using following code to bind my grid, i want to change default date filter to "is before or equal to" instead of "is equal to" and i want to hide all remaining filter options except "is before or equal to" and "is after or equal to"

     $(gridid).kendoGrid({
            dataSource: {
                data: dSource,
                schema: {
                    model: {
                        fields: {
                            Title: { type: "string" },
                            Location: { type: "string" },
                            Status: { type: "string" },
                            StartDate: { type: "date" },
                            Start: { type: "date" }
                        }
                    }
                },
                pageSize: 10
            },
            pageable: true,
            sortable: {
                mode: "single"
            },
            filterable: {
                mode: "row",
                operators: {
                    string: {
                        contains: "Contains"
                    }
                }
            },
            height: 450,
            columns: [
                {
                    field: "Title", title: "Title",
                    filterable: {
                        cell: {
                            operator: "contains"
                        }
                    }
                },
                {
                    field: "StartDate", title: "Start", template: "#= kendo.toString(Start, 'h:mm tt dd/MM/yy') #", width: "150px",
                    //filterable: {
                    //    cell: {
                    //        //template: datePicker,
                    //        operator: {                            
                    //            gte: "After or equal to",                            
                    //            lte: "Before or equal to",
                    //            eq: "On"
                    //        }                        
                    //    }
                    //}
                },

     ]
        });

  2. Answer
    Preslav
    Admin
    Preslav avatar
    516 posts

    Posted 24 Nov 2017 Link to this post

    Hello Muhammad,

    To achieve the desired behavior, set the filterable.operators.date.lte and filterable.operators.date.gte to the desired string.
    For example:

    //...
     filterable: {
        mode: "row",
        operators: {
          date: {
            lte: "Before or equal to",
            gte: "After or equal to"
          }
        }
      }
    //...


    For a runnable example, check my testing Dojo:

    Regards,
    Preslav
    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. Muhammad
    Muhammad avatar
    12 posts
    Member since:
    Aug 2015

    Posted 24 Nov 2017 Link to this post

    Thanks
Back to Top