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
2048
Load igGrid as PartialView in a div and Row Edit Dialog
posted

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:


    @Html.Partial("~/Views/Shared/Grid.cshtml", Model)

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

Parents
  • 23953
    Offline posted

    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.

Reply Children