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

  • 2048
    posted

    For example, also a function like the following one:

    $("#grid_1").live('iggridupdatingroweditdialogcontentsrendered', function (event, ui) {
            alert(123);
    });

    Prints 1 only the first time dialog is opened. But if I close it, I select antoher row and I press F2, the dialog appears without printing 123, i.e. dialog is considered as already rendered...