Hi
I had been adding to the following post (which relates to igGrid) but I think that I have a problem specific to igHierarchicalGrid so have started a new post:
http://ko.infragistics.com/community/forums/p/66850/432682.aspx#432682
I have an MVC 4 website running with ignite ui 13.1. My save button invokes a controller method which returns a JSON result, as described in the above post:
The controller save method ends like this:
Dictionary<string, object> response = new Dictionary<string, object>();string strResponseMessage = string.Empty;JsonResult result = new JsonResult();
if (strSaveResult.Length == 0){ response.Add("Success", true); result.Data = response;}else{ response.Add("Success", false); response.Add("ErrorMessage", strResponseMessage);}result.Data = response;return result;
I am using the igHierarchical grid bound to a dataset with two tables in a parent/child relationship.
The problem is that I can't seem to save my data and process the success/error message via a call to changesSuccessHandler. I can save my data or call changesSuccessHandler but I can't do both.
changesSuccessHandler is a javascript function in the view. The following code snippets are behind my save button's click event.
Lines like "$("#TimesheetGrid").igHierarchicalGrid("saveChanges");" call the save method in my controller (apart from in my first example with which no save happens at all - scripting error).
eg:
This does not work at all - my save processing does not invoke and throws an error:$("#TimesheetGrid").data("igHierarchicalGrid").dataSource._addChangesSuccessHandler(changesSuccessHandler);$("#TimesheetGrid").igHierarchicalGrid("saveChanges");
I get this in the browser console for this error, which makes me think that for some reason I can't add the success handler to a hierarchical grid:
Uncaught TypeError: Cannot call method '_addChangesSuccessHandler' of undefined VM132:3$.bind.click VM132:3f.event.dispatch jquery-1.7.1.min.js:3h.handle.i
This saves changes to my lower band but does not fire changesSuccessHandler:
$("#TimesheetGrid").data("igGrid").dataSource._addChangesSuccessHandler(changesSuccessHandler);$("#TimesheetGrid").igHierarchicalGrid("saveChanges");
This fires changesSuccessHandler but DOES NOT save the changes to my lower band of data:$("#TimesheetGrid").data("igGrid").dataSource._addChangesSuccessHandler(changesSuccessHandler);$("#TimesheetGrid").igGrid("saveChanges");
It feels like the changesSuccesSHandler callback only works for igGrid ie the first, top level, band in my data so I must be missing something here.
I am at a loss as to what to try next. I am using the changesSuccessHandler to display success or error messages depending upon what happens in the save.
Regards,
Graeme
Hello Graeme,
I'm following up on your question. Did you get a chance to upgrade to IgniteUI 13.2? Please let me know if you have any further questions.
Thank you,
Malav Patel
I needed a newer version of Ignite UI to implement your suggestion so I am just setting up a new virtual machine with Visual Studio 2013, Ignite UI 13.2, SQL Server.....
When I finally get to where I need to be I will let you know how I got on.
I'm following up with you to check if there are any more questions with the implementation suggested.
Hi Malav
Thanks for the response. I missed saveChangesSuccessHandler because I was looking under Events rather than Options. That all makes perfect sense and I shall give it a go.
I have just had a look at my Ignite UI version - I'm on 13.1.20131.2217 so I think that first step is for me to upgrade to the latest SR as my version pre-dates the release that you mentioned.
I'll mark your post as answer once I've upgraded and tried it out.
Thank you for your response. From 13.1.2292 we introduced a success and error callback parameters to the igDatSource.saveChanges and igGrid.saveChanges APIs. Also we added igGridUpdating.saveChangesErrorHandler and igGridUpdating.saveChangesSuccessHandler callback options. Unfortunately we didn’t add success and error callbacks to igHierarchicalGrid.saveChanges in 13.1.2292, but we will do this for the next SR.
In the meantime, you may be able to use igGridUpdating.saveChangesSuccessHandler option which will satisfy your needs because for performance reasons we make only one update request in igHierarchicalGrid.saveChanges (i.e. the first igGridUpdating.saveChangesSuccessHandler callback that will indicate that the AJAX operation was completed successfully). As a side effect you can experience several executions of igGridUpdating.saveChangesSuccessHandler, one for each layout which had pending changes.
Please also note that the GridUpdating.SaveChangesSuccessHandler and GridUpdating.SaveChangesErrorHandler are not working right now for grid MVC helper wrapper because of a bug, but that will be resolved in the next SR (planned for end of this week).
The link to using saveChangesSuccessHandler can be found under https://www.igniteui.com/help/api/2013.2/ui.iggridupdating#options. Here is an example code on how to initialize it on initialization time:
$("#grid").igHierarchicalGrid({
features: [
{
name: "Updating",
saveChangesSuccessHandler : function (data) {
// Put your code here
}
]
});
Or at runtime.
//Set
$("#grid").igGridUpdating("option", "saveChangesSuccessHandler", function(data) {
$("#message").text("Changes were saved successfully").fadeIn(3000).fadeOut(5000);
I hope this answers your questions.
Sincerely,