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

[Solved] Telerik Grid with OR statement

1 Answer 91 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Mario
Top achievements
Rank 2
Mario asked on 05 Jan 2011, 01:53 PM
Hi, 

I have encounterd an problem with Grids. I want to use OR statements with Filterable(), and I do not know how to accomplish that.

For an example. The code below use AND; I am looking for the result containing Manufacturer "Alpha" and Name "John".

<%= Html.Telerik().Grid(Model.Items)
        .Name("Grid")
        .PrefixUrlParameters(false)
        .Columns(columns =>
        {
            columns.Bound(o => o.Id).Width(200);
            columns.Bound(o => o.Manufacture).Width(200);
            columns.Bound(o => o.Name).Width(200);
            columns.Bound(o => o.Price).Width(200);
        })
        .DataBinding(dataBinding =>
        {
            dataBinding.Server().Select("Index", "Home", new { ajax = true });
            dataBinding.Ajax().Select("_Index", "Home").Enabled(true);
        })
        .Scrollable(scrolling => scrolling.Enabled(true))
        .Sortable(sorting => sorting.Enabled(true))
        .Pageable(paging => paging.Total(Model.TotalItems).PageSize(Model.PageSize))
        .Filterable(filtering => filtering.Filters(f =>
        {
        /* AND STATEMENT, notice the Manucature and Name*/
            f.Add(o => o.Manufacture).Contains("Alpha");
            f.Add(o => o.Name).Contains("John");
        }))
        .Groupable(grouping => grouping.Enabled(true))
        .Footer(true)
%>


But as I said, I want to use OR, see example below. Here I want the result from two Manufactures. I know that OR()-method does not exists, but I wanted to show you some psudo code what I want to accomplish. 

<%= Html.Telerik().Grid(Model.Items)
        .Name("Grid")
        .PrefixUrlParameters(false)
        .Columns(columns =>
        {
            columns.Bound(o => o.Id).Width(200);
            columns.Bound(o => o.Manufacture).Width(200);
            columns.Bound(o => o.Name).Width(200);
            columns.Bound(o => o.Price).Width(200);
        })
        .DataBinding(dataBinding =>
        {
            dataBinding.Server().Select("Index", "Home", new { ajax = true });
            dataBinding.Ajax().Select("_Index", "Home").Enabled(true);
        })
        .Scrollable(scrolling => scrolling.Enabled(true))
        .Sortable(sorting => sorting.Enabled(true))
        .Pageable(paging => paging.Total(Model.TotalItems).PageSize(Model.PageSize))
        .Filterable(filtering => filtering.Filters(f =>
        {
        /* OR STATEMENT, notice the Manufacture */
            f.Add(o => o.Manufacture).Contains("Alpha").OR().Contains("Beta");
        }))
        .Groupable(grouping => grouping.Enabled(true))
        .Footer(true)
%>


Do you have any bright ideas to conquer this problem?

Regards,
Mario

1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 05 Jan 2011, 03:55 PM
Hi Mario,

 The grid does not support OR filters from the filtering API. I am afraid there is no workaround because this needs to be implemented first.

Regards,
Atanas Korchev
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Mario
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Share this question
or