jQuery UI Widgets Forums Grid addrow and update row in the same function

This topic contains 4 replies, has 2 voices, and was last updated by  Dimitar 7 years, 11 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author

  • KBhima
    Participant

    Hi,
    I have four buttons “ADD, Edit, Save, Cancel” in my webpage.
    To Add data to the grid, Click on Add button and then Save button.
    To Edit the data in the grid, Click on Edit make changes and click save button to save it back to the grid.The data is added and edited on clicking the save button.
    How can I use “addrow” and “updaterow methods in the same “save function, below is my piece of code.

    ` $scope.save = function()
    {
    var data = {
    ClientId: $scope.clientIdSettings.jqxInput(‘val’),
    ClientName: $scope.clientNameSettings.jqxInput(‘val’)
    };
    $scope.gridSettings.jqxGrid(‘addrow’, null, data);
    var rows = $scope.gridSettings.jqxGrid(‘getrows’);
    $scope.gridSettings.jqxGrid(‘selectrow’,rows.length-1 );
    $scope.clientIdSettings.jqxInput(‘val’, ”);
    $scope.clientNameSettings.jqxInput(‘val’, ”);

    var rowID = $scope.gridSettings.jqxGrid(‘getrowid’, editrow);
    $scope.gridSettings.jqxGrid(‘updaterow’, rowID, data);
    $scope.clientIdSettings.jqxInput(‘val’, ”);
    $scope.clientNameSettings.jqxInput(‘val’, ”);

    };

    });


    KBhima
    Participant

    Also how can I cancel if I don’t want to edit or add? That is when I click on a row to edit and then without saving wanted to cancel it.

    Thanks,


    Dimitar
    Participant

    Hi KBhima,

    I think you can achieve this by using a flag variable (called, for example, mode). If “Add” is clicked, set mode to ‘add’. If “Edit” is clicked, set it to ‘edit’. In $scope.save, check for the value of mode and call either addrow or updaterow depending on its value.

    To cancel the add or edit action, you can have another button, “Cancel”, which clears the add/edit inputs.

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/


    KBhima
    Participant

    Am doing this for cancel, but it doesn’t work.

    $scope.cancel = function (row,event) {
    event.cancel =true;
    }

    It does not clear off anything.


    Dimitar
    Participant

    Hi KBhima,

    By “clearing the add/edit inputs” I meant setting their values (with val) to empty strings (“”).

    Best Regards,
    Dimitar

    jQWidgets team
    http://www.jqwidgets.com/

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

You must be logged in to reply to this topic.