This is a migrated thread and some comments may be shown as answers.

change default date filter & reduce filter options

2 Answers 464 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Muhammad
Top achievements
Rank 1
Muhammad asked on 23 Nov 2017, 07:27 AM

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 Answers, 1 is accepted

Sort by
0
Accepted
Preslav
Telerik team
answered on 24 Nov 2017, 07:02 AM
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.
0
Muhammad
Top achievements
Rank 1
answered on 24 Nov 2017, 09:22 PM
Thanks
Tags
Grid
Asked by
Muhammad
Top achievements
Rank 1
Answers by
Preslav
Telerik team
Muhammad
Top achievements
Rank 1
Share this question
or