pvaju896
pvaju896

Reputation: 1417

Grid.MVC to bind with specific condition

Scenario: Using Grid.Mvc, and binding it with ViewBag(this contains model list). I have model appointment's list in a viewbag. and in UI i have two grids, one for showing visited appointments, other for appointments which are not visited.

Grid 1: HasVisited == True
Grid 2: HasVisited == False

@Html.Grid(Model).Named("Grid1").Columns(columns =>
                 {
                    columns.Add(c => c.StartTime).Titled("Date").Filterable(true).Sortable(true);
                    columns.Add(c => c.Patient).Titled("Patient").Filterable(true).Sortable(true);
                }).WithPaging(10).Sortable(true)

The above is the Grid.Mvc grid implementation. Do we have any ways to bind the grid with specified condition.?

Upvotes: 1

Views: 546

Answers (2)

Viplock
Viplock

Reputation: 3319

Just Change Model to Model.Where(d=>d.HasVisited==true) for filtering the data.

Upvotes: 1

pvaju896
pvaju896

Reputation: 1417

After modification;

@Html.Grid(Model.Where(d=>d.HasVisited==true)).Named("Grid1").Columns(columns =>
                 {
                    columns.Add(c => c.StartTime).Titled("Date").Filterable(true).Sortable(true);
                    columns.Add(c => c.Patient).Titled("Patient").Filterable(true).Sortable(true);
                }).WithPaging(10).Sortable(true)

Upvotes: 0

Related Questions