Filter with multiple default values

2 posts, 0 answers
  1. Sam
    Sam avatar
    18 posts
    Member since:
    Aug 2015

    Posted 10 Nov 2017 Link to this post

    Hi,

    I have a grid that contains this column (simplified for clarity):

    columns.Bound(c => c.Status)
        .Filterable
        (
            f => f.Extra(false).Multi(true).CheckAll(true).BindTo
            (new[]
            {
                        new { Status = "New" },
                        new { Status = "Started" },
                        new { Status = "Completed" }
            })
        );

     

    I want both "New" and "Started" to be checked by default when the page is first displayed.

    In the DataSource, I have this code:

    .DataSource
    (
        .Filter
        (
            f => f
            .Add(x => x.Status).IsEqualTo("New")
        )
    )

     

    However, I cannot figure out how to add a second value, "Started", so that both are checked by default. How can I do this?

    Thanks.

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    2480 posts

    Posted 14 Nov 2017 Link to this post

    Hello Sam,

    In order to add multiple options when filtering by one field you can use the configuration below:

    .Filter(f => f.Add(x => x.Status).IsEqualTo("New").Or().IsEqualTo("Started"))


    On a side note, if you would like to specify a more complex filter that includes multiple fields you can define an object and pass the filter configuration:


    .Filter(f=> {
            f.Add(x => x.ShipName).Contains("Sup");
            f.Add(x => x.Freight).IsGreaterThan(100);
        })


    Regards,
    Viktor Tachev
    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.
Back to Top