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()
}
$("#grid").igGridColumnMoving("moveColumn", "ProductID", "Name", false);
.Columns(column => { column.For(x => x.ProductName).HeaderText("Name").Width("150px"); column.For(x => x.Rating).HeaderText("Rating").Width("150px"); column.For(x => x.ID).HeaderText("ID").Width("150px"); })
.Columns(column => { column.For(x => x.ProductName).HeaderText("Name").Width("150px").Hidden(true); column.For(x => x.Rating).HeaderText("Rating").Width("150px"); column.For(x => x.ID).HeaderText("ID").Width("150px"); }} })
ColumnSettings(settings => { settings.ColumnSetting().ColumnKey("ProductName").Hidden(true).AllowHiding(false); })
$(document).delegate("#grid", "iggridcolumnmovingcolumnmoved", function (evt, args) { alert("old index: " + args.newIndex + "\nnew index: " + args.oldIndex + "\ncolumnKey: " + args.columnKey); });
$(document).delegate("#grid", "iggridhidingcolumnhidden", function (evt, ui) { console.log(ui); alert("columnKey: " + ui.columnKey); });
Martin,
Thanks for your reply. I realized that I do not need to call .DataBind() on the wrapper.
That seemed to have fixed the initial problem.
Also, I thought I understood that if I use the Wrapper and Paging is set to Remote, The GridDataSourceAction attribute handles the remote paging on the server automatically, so the paging logic on the server is not needed. Is this correct?from
help.infragistics.com/.../igGrid_Paging.html
I have run into another problem however. I know the pageSize and filter parameters come in to the controller through the query string. If I want to capture other changes to the grid; such as: column moved (position), or column hidden. How would I 1) set those initially in the code behind, and 2) capture those events to save the values in the database? It doesn't look like those parameters get sent to the server when changed.
Hello,Thank you for posting in our community.After testing the grid configuration provided I didn’t manage to reproduce the behavior. I added a column with key “Rating”. Afterwards, I set a DefaultFilterExpression for this column and all rows were correctly loaded, depending on page size.Attached you will find the updated sample where the initial Filtering works fine. Feel free to test it and let me know if it works on your side. In case this is not a correct representation of what you are trying to achieve feel free to correct me.
sample
Tsanna,
I have implemented your example to set initial filter values. The initial filtering seems to work and the value in the filter get set; however, the grid initially only renders two rows on the first page. The page size is set to 25 and the info at the bottom of the grid shows just the number of records and the number of pages is the number of unfiltered records. When I execute an event (go to the next page) the grid shows the correct number of filtered records and correct pages. But, only after I go to page 2. I remove the .DataBind() from the wrapper everything works correctly, but the grid looks like it takes a second or two to render now (shows the loading image) instead of rendering before the grid shows on the page. I feel like the .DataBind() should be there on the wrapper. What am I doing wrong and why does this happen?
here is my code for the wrapper:
@(Html.Infragistics() .Grid(Model.Employees) .ID("grid") .AutoGenerateColumns(false) .Width("100%") .Columns(column => { column.For(x => x.FullName).HeaderText("Name").Width("150px"); column.For(x => x.SystemAssignedPersonID).HeaderText("System ID").Width("150px"); column.For(x => x.UserAssignedEmployeeID).HeaderText("Employee ID").Width("150px"); column.For(x => x.BadgeNumber).HeaderText("Badge Number").Width("150px"); column.For(x => x.OriginalHireDate).HeaderText("Original Hire Date").Width("150px"); column.For(x => x.CurrentHireDate).HeaderText("Current Hire Date").Width("150px"); column.For(x => x.FulltimeHireDate).HeaderText("Fulltime Hire Date").Width("150px"); column.For(x => x.SeniorityDate).HeaderText("Seniority Date").Width("150px"); column.For(x => x.DateNewHireReportFiled).HeaderText("Date New Hire Report Filed").Width("150px"); column.For(x => x.LaidOffDate).HeaderText("Laid Off Date").Width("150px"); column.For(x => x.LeaveDate).HeaderText("Leave Date").Width("150px"); column.For(x => x.LeaveReturnDate).HeaderText("Leave Return Date").Width("150px"); column.For(x => x.LastPaidDate).HeaderText("Last Paid Date").Width("150px"); column.For(x => x.LastVacationDate).HeaderText("Last Vacation Date").Width("150px"); column.For(x => x.PensionPlanDate).HeaderText("Pension Plan Date").Width("150px"); column.For(x => x.RecruiterID).HeaderText("Recruiter ID").Width("150px"); column.For(x => x.HireSourceID).HeaderText("Hire Source ID").Width("150px"); column.For(x => x.Level1Description).HeaderText("Level 1").Width("150px"); column.For(x => x.Supervisor).HeaderText("Supervisor").Width("150px"); column.For(x => x.EmploymentTypeDescription).HeaderText("Employment Type").Width("150px"); column.For(x => x.EmployeeStatusDescription).HeaderText("Employee Status").Width("150px"); column.For(x => x.TerminationDate).HeaderText("Termination Date").Width("150px"); }) .FixedHeaders(false) .Features(features => { features.Paging().Type(OpType.Remote); features.Filtering().Type(OpType.Remote).FilterDialogContainment("window") .ColumnSettings(settings => settings.ColumnSetting().ColumnKey("EmployeeStatusDescription").DefaultExpressions(Model.GridFeatureSettings.dfe)); features.Sorting().Type(OpType.Remote).Mode(SortingMode.Single); features.Resizing(); features.Selection().Mode(SelectionMode.Row).Persist(true).MultipleSelection(true); features.ColumnFixing(); features.ColumnMoving(); features.Hiding(); }) .DataSourceUrl(Url.Action("Employees")) .DataBind() .Render())
GOod one thanks for this kind of information google mail for more detials