|
. . . .
@(Html.EJ().Grid<object>("FlatGrid")
. . . .
.AllowSearching()
.ClientSideEvents(eve => { eve.DataBound("dataBound"); })
.ToolbarSettings(toolbar =>
{
toolbar.ShowToolbar().ToolbarItems(items =>
{
items.AddTool(ToolBarItems.Search);
});
})
. . . . . .
<script type='text/javascript'>
var col = []; // create an empty array to store the searchable columns
function dataBound(args) { // triggers when data bind to grid
for (i = 0; i < args.model.columns.length; i++) {
if (args.model.columns[i].field != "CustomerID") { // check the condition for non-searchable column
col.push(args.model.columns[i].field); // push all the searchable columns to variable
}
}
this.option({ searchSettings: { fields: col } }) // enable searching with the required columns here
}
</script>
|