<input id="btn" type="button" value="filter" onclick="btnclick()" />
@(Html.EJ().Grid<MvcApplication1.OrdersView>("FlatGrid") .Datasource((IEnumerable<object>)ViewBag.datasource) .AllowPaging() /*Paging Enabled*/ .AllowFiltering() .Columns(col => { col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add(); col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Format("{0:C}").Add(); col.Field("OrderDate").HeaderText("Order Date").TextAlign(TextAlign.Right).Width(80).Format("{0:MM/dd/yyyy hh:mm:ss}").Add(); }) )
<script type="text/javascript">
function btnclick() { var obj = $("#FlatGrid").ejGrid("instance"); obj.model.filterSettings.filteredColumns.push({ field: "OrderDate", operator: "lessthanorequal", value: new Date("11/11/1997"), matchcase: false, predicate: "and" }); obj.model.filterSettings.filteredColumns.push({ field: "OrderDate", operator: "greaterthanorequal", value: new Date("05/06/1997"), matchcase: false, predicate: "and" });
obj.refreshContent();//refresh the grid content } |