Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
Sending Form & Grid data to Controller
posted

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();

Parents
No Data
Reply
  • 24671
    Verified Answer
    posted

    Hi,

    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 

Children