I'd like an example of saving the user settings of the igGrid to the database and restoring these settings when the grid loads. I've found a few examples of this using the igGrid on the client-side, but I'd like to see how to do this using either Chaining or GridModel. I have this working loading the settings to the GridModel, but I need help capturing the entered values from the client and saving to the server.
Thanks in advance for your help.
Any help with this would be greatly appreciated. Thanks
Hello ericl,
Thank you for posting in our forum.
In order to be sure I understand your scenario and your question is addressed correctly, some additional information would be greatly appreciated:
Looking forward to hearing from you.
Hello Vasil,
Thank you for your reply. To answer to your questions:
Here is my code so far:
In the View:
@(Html.Infragistics() .Grid(Model.Employees) .ID("grid") .PrimaryKey("SystemAssignedPersonID") .AutoGenerateColumns(false) .Width("100%") .Columns(column => { column.For(x => x.FullName).HeaderText("FullName").Width("150px"); column.For(x => x.SystemAssignedPersonID).HeaderText("SystemAssignedPersonID").Width("150px"); column.For(x => x.CompanyID).HeaderText("CompanyID").Width("150px"); column.For(x => x.UserAssignedEmployeeID).HeaderText("UserAssignedEmployeeID").Width("150px"); column.For(x => x.BadgeNumber).HeaderText("BadgeNumber").Width("150px"); column.For(x => x.EmployeeStatusID).HeaderText("EmployeeStatusID").Width("150px"); column.For(x => x.EmploymentTypeID).HeaderText("EmploymentTypeID").Width("150px"); column.For(x => x.OriginalHireDate).HeaderText("OriginalHireDate").Width("150px"); column.For(x => x.CurrentHireDate).HeaderText("CurrentHireDate").Width("150px"); column.For(x => x.FulltimeHireDate).HeaderText("FulltimeHireDate").Width("150px"); column.For(x => x.SeniorityDate).HeaderText("SeniorityDate").Width("150px"); column.For(x => x.DateNewHireReportFiled).HeaderText("DateNewHireReportFiled").Width("150px"); column.For(x => x.LaidOffDate).HeaderText("LaidOffDate").Width("150px"); column.For(x => x.LeaveDate).HeaderText("LeaveDate").Width("150px"); column.For(x => x.LeaveReturnDate).HeaderText("LeaveReturnDate").Width("150px"); column.For(x => x.LastPaidDate).HeaderText("LastPaidDate").Width("150px"); column.For(x => x.LastVacationDate).HeaderText("LastVacationDate").Width("150px"); column.For(x => x.PensionPlanDate).HeaderText("PensionPlanDate").Width("150px"); column.For(x => x.RecruiterID).HeaderText("RecruiterID").Width("150px"); column.For(x => x.HireSourceID).HeaderText("HireSourceID").Width("150px"); column.For(x => x.EmploymentTypeDescription).HeaderText("EmploymentTypeDescription").Width("150px"); column.For(x => x.EmployeeStatusDescription).HeaderText("EmployeeStatusDescription").Width("150px"); column.For(x => x.Level1Description).HeaderText("Level1Description").Width("150px"); column.For(x => x.Supervisor).HeaderText("Supervisor").Width("150px"); column.For(x => x.TerminationDate).HeaderText("TerminationDate").Width("150px"); }) .FixedHeaders(false) .Features(features => { features.Paging().Type(OpType.Remote); features.Filtering().Type(OpType.Remote).ColumnSettings( x=> x.ColumnSetting().DefaultExpressions(Model.GridFeatureSettings.ColumnFilterSetting.DefaultExpressions)); features.Sorting().Type(OpType.Remote).Mode(SortingMode.Single); features.Resizing(); features.Selection().Mode(SelectionMode.Row); features.ColumnFixing(); features.ColumnMoving(); features.Hiding(); }) .DataSourceUrl(Url.Action("Employees")) .DataBind() .Render())
Controller methods:
[HttpGet] public ActionResult Index() {
var employees = _employeeService.GetAuthorizedEmployees(companyID, userID);
var model = new EmployeeSelectMode();
model.Employees = employees.AsQueryable();
// setting initial filters
ColumnFilteringSetting colFilteringSetting = new ColumnFilteringSetting(); colFilteringSetting.ColumnKey = "EmployeeStatusDescription"; colFilteringSetting.DefaultExpressions.Add(new DefaultFilterExpression() { Expression = "Terminated", Condition = "doesNotEqual" });
model.GridFeatureSettings.ColumnFilterSetting = colFilteringSetting; return this.View("EmployeeSelect", model); }
[GridDataSourceAction] public ActionResult Employees() { var employees = _employeeService.GetAuthorizedEmployees(this.CurrentUser.CompanyID, this.CurrentUser.UserID);
var employees = _employeeService.GetAuthorizedEmployees(companyID, userID); return this.View(employees.AsQueryable()); }
Thank you for the provided details.
As this is a custom scenario and the igGrid doesn’t support this functionality out-of-the-box, I am in the process of investigating which approach would best allow to fulfill the requirement that you have and I will get back to you tomorrow with more information regarding this matter.
Please feel free to contact me with any updates or additional questions regarding this scenario in the meantime.
Thanks Vasil,
I have a solution for filtering and paging; those are accessible via the controller using the GridDataSourceAction attribute and requesting those parameters from the query string, but I will need to find a solution for setting and saving other features including column moving, hiding, fixing. I can't seem to figure out how to access these events from the server at the time when the grid is changed by the user. Those parameters are not passed in the query string.