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

Filter with multiple default values

1 Answer 2436 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 10 Nov 2017, 03:41 PM

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.

1 Answer, 1 is accepted

Sort by
1
Viktor Tachev
Telerik team
answered on 14 Nov 2017, 01:31 PM
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.
Ganesh
Top achievements
Rank 1
commented on 24 Aug 2021, 05:41 AM

Hi, Victor can i add condition in the below filter 

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

Viktor Tachev
Telerik team
commented on 25 Aug 2021, 02:52 PM

Would you elaborate in more detail on what is the functionality you would like to implement?
Tags
Grid
Asked by
Sam
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Share this question
or