Can someone point me in the right direction? Using MVC, I have a web page that displays a grid with filters. I can manually filter records, however I would like to have one column (named "Active") to be filtered when the page loads as if the user had selected the filter Active = True. The page downloads all records (regardless of Active status) so that the user could chose to clear the filter and see all records without another roundtrip.
I looked through the online docs and samples but could not find where the specific MVC syntax for this is documented.
Below is what I have so far, but the filter initialization doesn't work and it displays all records.
Thanks in advance for your help.
@using Infragistics.Web.Mvc;
@model IQueryable<STRIPE_ASP461.EmployeeSummaryInfo>
@section Scripts {
<script type="text/javascript" src="@Url.Content("~/Scripts/Infragistics/js/infragistics.loader.js")"></script>
@(Html.Infragistics()
.Loader()
.ScriptPath(Url.Content("~/Scripts/Infragistics/js"))
.CssPath(Url.Content("~/Content/Infragistics/css"))
.Theme("infragistics")
.Render())
.Grid(Model)
.ID("igGrid")
.Width("600px")
.Height("800px")
.Caption("Employees")
.AutofitLastColumn(false)
.AutoGenerateColumns(false)
.Columns(column =>
{
column.For(x => x.LastName).HeaderText("Last Name").Width("150px");
column.For(x => x.FirstName).HeaderText("First Name").Width("150px");
column.For(x => x.EmployeeID).HeaderText("ID").Width("80px");
column.For(x => x.Active).HeaderText("Active").Width("50px");
})
.Features(f =>
f.ColumnMoving()
.Mode(MovingMode.Immediate);
f.Filtering()
.Type(OpType.Local)
.Mode(FilterMode.Simple)
.ColumnSettings(settings => {
settings.ColumnSetting() // Initially just show the Active records
.ColumnKey("Active")
.FilterCondition("true");
});
f.Hiding();
f.Paging()
.PageSize(20);
f.Resizing();
f.Responsive();
f.Selection()
.Mode(SelectionMode.Row);
f.Sorting()
.Mode(SortingMode.Multiple);
.RenderCheckboxes(true)
.DataBind()
}
I still couldn't find the correct Razor syntax, but this worked to add the following JavaScript right after the Razor call:
.Render())...
<script type="text/javascript">
$.ig.loader(function () {
// Initially just show the Active records
$("#igGrid").igGridFiltering("filter", ([{ fieldName: "Active", expr: "True", cond: "true" }, ]));
</script>
Hello Dean,
In order to set initial filtering expressions, so that they're applied with the grid initialization, you should use defaultExpressions columnSetting. For instance:
[code]
@{
var list = new List<DefaultFilterExpression>();
list.Add(new DefaultFilterExpression(){ Expression="false", Condition="false"});
...
f.Filtering().Mode(FilterMode.Simple).Type(OpType.Local).ColumnSettings(settings =>
settings.ColumnSetting().ColumnKey("Active").DefaultExpressions(list);
[/code]
If you need further assistance, please let me know.
Regards,
Tsanna
Hi Tsanna,
Thank you for the code example! That helps to keep all the grid & filter initialization together.
Dean
Hi Dean,
You're welcome. If you need further assistance, please let me know.
GOod one thanks for this kind of information google mail for more detials