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
160
Delete Row on Client Side
posted

Hello, i am trying to delete my rows on client side, with this code:


function arqGrid_Eliminar(idGrid, rowKey, eliminarKey, callingURL) {
    ShowInProgress()

    var grid = $find(idGrid);
    var parentGrid = grid.get_gridView();

    var numberOfRows = parentGrid.get_rows().get_length();

    var response = []
    var rowKey = rowKey;
    for (i = 0; i < numberOfRows; i = i + 1) {
        if (parentGrid.get_rows().get_row(i).get_cellByColumnKey(eliminarKey).get_value()) {
            var rowKeyValue = parentGrid.get_rows().get_row(i).get_dataKey()[0]
            response.push({ rowKey: rowKey, rowKeyValue: rowKeyValue })
        }
    }

    var object = { Deletes: response };
    var rows = []

    $.ajax({
        url: DIR_VIRTUAL + callingURL + '/Eliminar',
        type: "POST",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        data: JSON.stringify(object),
        cache: false,
        async: false,
        success: function (data) {
             for (i = 0; i < numberOfRows; i = i + 1) {
                if (parentGrid.get_rows().get_row(i).get_cellByColumnKey(eliminarKey).get_value()) {
                     var row = parentGrid.get_rows().get_row(i);
                     var rowKeyValue = row.get_dataKey()[0]
                     //Si no ha dado error se elimina
                     if (($.inArray(rowKeyValue.toString(), data.d) < 0)) {                      
                         //row._element.style.display = "none"

                           //parentGrid.get_rows().remove(row)

                       //parentGrid.get_behaviors().get_editingCore().get_behaviors().get_rowDeleting().deleteRows(row)

                     }
                           
                }
            }            
        },
        complete: function () {
            HideInProgress()
            //Muestra el mensaje resultado de la operacion, el cual habra sido guardado en sesión
            parent.MostrarMensaje()
        },
        error: function (jqXHR, textStatus, errorThrown) {
            HideInProgress();
            alert(textStatus)
        }
    });

    //Refresh Grid
    //var callbackObject = grid._callbackManager.createCallbackObject();
    //grid._callbackManager.execute(callbackObject);

    return false;   
 
}

The Ajax call deletes the row on database and on session.

but then when i made a post it shows a error message, i attached the snapshot to the post.

Regards, Juan