Grid Custom Filter with Preset value

3 posts, 0 answers
    RICHARD  avatar
    3 posts
    Member since:
    Mar 2016

    Posted 03 May 2016 Link to this post


    I have a column in my Grid with a custom filter which has pre-populated values in a dropdown. When user opens the page I want the default value to be set to a value that I pass from the Controller in ViewData. I'm able to set the grid filtered to a value on page load but the dropdown in the filter does not have the value selected.

    Grid has the below column

     columns.Bound(c => c.DealYear).Filterable(filterable => filterable.UI("yearFilter")).Width(70);

    with the below options set

    .Filterable(filterable => filterable
            .Operators(operators => operators
               .ForString(str => str.Clear()
                   .StartsWith("Starts with")
                   .IsEqualTo("Is equal to")
                   .IsNotEqualTo("Is not equal to")


    And on page load I filter the grid with a value passed from Controller  - This works fine.

      .Filter(f =>f.Add(p => p.DealYear).Equals(ViewData["DealYear"]))


    But in my javascript, how do I set the value to the Filter Dropdown?

    function yearFilter(element) {
                dataSource: {
                    transport: {
                        read: "@Url.Action("FilterMenuCustomization_DealYear")"
                optionLabel: "--Select Year--"


    The page loads with a predefined filter but the dropdown in the Filter shows 'Select Year'.



  2. Milena
    Milena avatar
    244 posts

    Posted 04 May 2016 Link to this post

    Could you verify if this demo presents the desired behavior? I would recommend you to follow the approach of the example in order to achieve the same behavior. In case you would like another solution, could you explain in detail the expected result?

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
    RICHARD  avatar
    3 posts
    Member since:
    Mar 2016

    Posted 04 May 2016 in reply to Milena Link to this post


    Thank you for your reply. I have fixed the problem by changing the Equals to IsEqualTo in the Filter.

     .Filter(f =>f.Add(p => p.DealYear).IsEqualTo(Convert.ToInt32(ViewData["DealYear"])))

Back to Top