Hi,
I have a ASP.Net MVC 3 application where we display a page with a form and a grid, which is bound to a collection property of the page model.
We want to do a batch update and at the same time submit the form, and both savings should be done "transactionally". That is saved in one go.
I don't know if there is a better way of doing this, but I have come up with the following sollution.
- The submmit button calls a javascript function that calls the grid saveChanges, and the form submit.
- The action in the controller for the Grid Update saves the changes in session so the form submit method in the controller can extract that data from there and update the models appropiately and carry on the call to the Service layer.
My problem is that I don't know how to ensure that the form submit is called just after the grid changes have been commited.
I have been able to achieve that by doing an active wait on the PendingTransactions property, so I call the form submit just once there is no transaction pending, but this is a very ugly solution that causes the browser to hang for while.
What it would be great is to be able to subscrive the the Save Changes callback but I haven't been able to find if that is possible.
Is there any other way of doing that?
// Send grid data to controller
$(
"#grid1").igGrid("saveChanges");
// Wait for the data to be commited
var len = $("#grid1").igGrid("pendingTransactions").length;
while (len != 0) {
len = $("#grid1").igGrid("pendingTransactions").length;
// Send form data to the Controller
"#LookupForm").submit();
The best approach to solve this problem is to have an event which gets fired after the changes are successfully comitted and the response comes back to the server, that is , what you are suggesting.
We are going to implement this event, and it should be in the next service release.
Thanks for the feedback.
Angel
Thanks Angel.
When is the next service release planned? Any cahance of having an early sight of the new event? :)
I was thinking to do a dirty change myself, but not sure how hard will be to trigger new events or how the live method handle event subscription. But if the next release is soon enough we will probably wait for it.
Juan
Yeah, that would be great :)
Looking forward it
Thanks for all Angel.
Hi Juan,
it will be out probably in a month from now. Hope that works for you.
Thanks,