I would like to update my grid using datasourceurl, but allow local sorting that is maintained after the datasourceurl is updated. Is this possible?
Here's a basic scenario of what I'd like to happen:
-Grid is initially loaded.
-User sorts grid by clicking on a column header.
-User selects a different option from some dropdown.
-Grid's data is updated, but the sorting of the column is retained.
Here's what I've tried so far:
client-side:
var url = getNewUrlFromSomeDropDown();
$myGrid.igGrid('option', 'dataSource', url);
...which causes that url to be hit, which does something like this (MVC / C#):
server:
Example 1 (doesn't work at all, grid is blank):
public ActionResult _Employee_Grid(int someFilteringInt)
{ List<Employee> employees = GetEmployees(someFilteringInt); return Json(employees, JsonRequestBehavior.AllowGet);
}
Example 2 (Populates grid with new data, but the data is not sorted in any particular way, and the sorting arrows are lost.)
public ActionResult _Employee_Grid(int someFilteringInt) { List<Employee> employees = GetEmployees(someFilteringInt);
GridModel model = new GridModel(); GridSorting sorting = new GridSorting(); sorting.Mode = SortingMode.Single; model.Features.Add(sorting); model.DataSource = employees.AsQueryable<Employee>(); return model.GetData(); }
Also, in the 2nd example, I must add the sorting feature to the model, or else sorting is lost all together. This means that the GetData() method generates different JSON data depending on the features and properties of the grid? If so, this doesn't make sense IMO. GetData should have nothing to do with the grid's setup. It sort of defeats the purpose of only reloading the data instead of the entire grid.
Thanks in advance for any help!
Hello Josh,
Thank you for your patience. I have finished my sample. I have been able to rebind the grid on button click without an issue. After clicking the button to change the data I am still able to sort the grid. Do you have an isolated sample that reproduces this behavior? What version of the jQuery product are you using?
Sincerely,Mike P.Developer Support EngineerInfragistics, Inc.www.infragistics.com
Thank you for your patience. I am still looking into this matter. Currently I am working on getting the grid to rebind on button click to simulate your dropdown where you select your different datasources. I will continue to look into this matter and will give you a progress update by the end of the day tomorrow.
Thank you for the update. By your description this seems like it may be an issue with the igGird control. I am currently investigating this matter further to see what is happening and causing this behavior. I am attaching my sample in its current state. I will continue to look into this matter and will give you a progress update by the end of the day Monday.
Any news on this? Our project is being held up until we can get these grids working properly. If, in fact, there is no built-in way to refresh the data while maintaining the grid's features (sorting, etc.), please just let me know so I can either accommodate this and move on, or move to another grid that supports this.
Just to be clear, in my last post (you can't edit posts in this forum for some reason) I mean that I am setting the datasource with a .Net object. I'm not setting the dataSourceUrl like before.