Hi,
I have a very big problem to solve. I found out this strange behavior, and I understood what it is, but I don't know in which way to solve it.
I have a grid definde by controller side, on which I've enabled the RowEditTemplate GridEditMode.By view side I catch the event related to the dialog close:
$("#grid_1").live('iggridupdatingroweditdialogclosed', function (event, ui) { if (event.buttons == 0) { $("#grid_1").igGrid("saveChanges"); window.setTimeout("refreshPartialView()", 1000); } });In this way I am able to understand if the Ok button has been clicked (event.buttons==0), therefore call the saveChanges UpdateUrl. After 1 second, time I set just to be sure that record has been placed in the db, I refresh just only the grid, calling the refreshPartialView js method:
function refreshPartialView() { $('#div_1').load( "/ControllerName/RefreshAction", { id: $('#id_text').val() }, function (response, status, xhr) { if (status == "error") { alert(status); } }); }
This method correctly calls the controller action that correctly returns the igGrid partial view. "Refreshed" grid is loaded in the div:
Until here NO PROBLEMS: grid is correctly loaded and showed.When does the problem start? NOW: if I select a row and try to edit it, dialog correctly appears, but iggridupdatingroweditdialogclosedevent is not caught, and sosaveChangesis not called anymore.
I noted that all igGrid-catchEvents-methods still works after the refresh: for example I have an iggridselectionrowselectionchanged event that is still caught by the javascript, after the partial view load too. Just row edit dialog events are not caught...
Do yu have any ideas? Is it possible that I have to destroy the dialog once I refresh the igGrid? How?
Thanks in advance
Flavio
Hi Flavio,
I'm not sure why are you reloading the partial view. When you call igGrid.saveChanges the changed data will be send to the server. There is no need to reload the partial view.
However if you need to refresh the grid data you can rebind the grid and get only the JSON from the server.
I didn't play with partial views much so I cannot say when igGrid code gets executed(or if it gets executed at all), because igGrid code is wrapped in either $(function() {/*igGrid initialization code*/}) or $.ig.loader(function() {/*igGrid initialization code*/}).
Hope this helps, Martin Pavlov
Infragistics, Inc.
Hi Martin,
thanks for your answer.
You're right: what I need to do is to refresh data. This is important because it's true that with saveChanges changes are sent to the server, and the grid already shows differences. But if another user, in the meanwhile, applies some changes on the data, in my view I am able to see only my changes, this is why I need to refresh data: I want to see mine(already in) and other users ones (not already visible in the data on which I am working).
Anyway, it's not important why I need it, but I am interest in your answer, about "rebind the grid and get only the JSON from the server". Could you post me a link with a sample? I would like to see if this can be my case (I think it should be more clear to rebind th grid than my solution with div reload...).
Thanks