jQuery UI Widgets Forums Grid Custom 'deleterow' function

This topic contains 3 replies, has 2 voices, and was last updated by  Peter Stoev 10 years, 11 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • Custom 'deleterow' function #16723

    dujmovicv
    Participant

    Hi JQWidgets users,

    I’d like to know if the ‘deleterow’ is a generic function of the JQW grid system or it can be copied and customized? I.E. I’m using this function to set a flag “deleted” to 1 in a database :

    deleterow: function (rowid, commit) {
    // synchronize with the server - send delete command
    var data = "recycle=true&id=" + rowid;
    $.ajax({
    dataType: 'json',
    url: 'grid/jqwidgets/controllers/trash_files_controller.php',
    data: data,
    success: function (data, status, xhr) {
    // delete command is executed.
    commit(true);
    }
    });
    },

    but I also need another function (let’s call it ‘delete_forever’) which will permanently delete the row :

    delete_forever: function (rowid, commit) {
    // synchronize with the server - send delete command
    var data = "delete_forever=true&id=" + rowid;
    $.ajax({
    dataType: 'json',
    url: 'grid/jqwidgets/controllers/trash_files_controller.php',
    data: data,
    success: function (data, status, xhr) {
    // delete command is executed.
    commit(true);
    }
    });
    },

    This is NOT working and I’m not sure why… Does the library recognize at all this function name (‘delete_forever’) or those functions are generic (deleterow, updaterow, etc, etc…)?
    Thank you in advance.

    Custom 'deleterow' function #16727

    Peter Stoev
    Keymaster

    Hi dujmovicv,

    If you want to delete a row in jqxGrid, you should use its “deleterow” method.
    If you want to synchronize the deleted row with your server, you should define a “deleterow” function to the source object associated to the jqxGrid. The Grid’s deleterow method will internally call the “deleterow” function(if it is defined).

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Custom 'deleterow' function #16737

    dujmovicv
    Participant

    I see. So I cannot define a new method ‘delete_forever’ (as mentioned above). Is there a way to pass another variable (do_what) to the method ‘deleterow’ to set the ‘data’ dynamically? I.E. :

    deleterow: function (rowid, commit) {
    // synchronize with the server - send delete command
    switch (do_what) {
    case 'restore':
    var data = "restore_file=true&id=" + rowid;
    break;
    case 'delete_forever':
    var data = "delete_forever=true&id=" + rowid;
    break;
    }
    $.ajax({
    dataType: 'json',
    url: 'grid/jqwidgets/controllers/trash_files_controller.php',
    data: data,
    success: function (data, status, xhr) {
    // delete command is executed.
    commit(true);
    }
    });
    },

    Thank you in advance.
    Best regards.

    Custom 'deleterow' function #16740

    Peter Stoev
    Keymaster

    Hi dujmovicv,

    It depends on your scenario how you define your “deleterow” function. There are only 2 things to keep in mind – call commit(true) if the synchronization is OK(that will confirm the changes in the UI) and call commit(false) if the synchronization fails(that will cancel the UI updates. The “deleterow” function’s name should be “deleterow” Otherwise, it will not be called.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.