rrgirish
rrgirish

Reputation: 331

Get only specific rows in MVC based on a column value

I have the following code to get data in MVC and show in the page:

@Html.Grid(Model).Named("profilesGrid").AutoGenerateColumns().Columns(columns =>
{
    columns.Add(d => d.ProcessingStatus).Titled("Processing Status").Sortable(true).Filterable(true);;
    columns.Add(d => d.CheckListDate).Format("{0:MM/dd/yyyy hh:mm:ss tt}").Sortable(true).Filterable(true);
}).WithPaging(20).Sortable().Filterable().WithMultipleFilters()

I want to only show data where the ProcessingStatus= "OrderCompleted"

Any ideas on how to do this?

Upvotes: 1

Views: 1594

Answers (1)

Dave Ward
Dave Ward

Reputation: 60570

Is Model.Where(m => m.ProcessingStatus == "OrderCompleted") the data you need? You could always do that inline right there in the Html.Grid().

If you always want to filter to just those rows and don't need the other rows for anything else on the page, it would make more sense to filter it in your controller, view model, etc. before sending it to the view.

Upvotes: 2

Related Questions