jQWidgets Forums

Forum Replies Created

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

  • ben25
    Participant

    Hi Peter

    Thanks, that is good news already.
    Unfortunately I don’t know how to do this. I tried many time but I didn’t figure out what is wrong in my code.

    Any help would be the welcome.
    I’m surprise how difficult it could be to delete multiple selected rows by a checkbox in a grid.


    ben25
    Participant

    Hi Peter

    Can you confirm me that I can use selectionmode checkbox and delete the selected row?

    My page is based on the example you told me. Where Im struggling is to combine selection mode checkbox and the deletebuttonclick.
    Im a bit lost honestly. I assume my PHP page is ok. I used the demo page in the download package and I just changed mysqlconnect and query to PDO.

    I tried already this:

    $("#deleteRows").click(function () {
       var rowIndexes = $('#jqxgrid').jqxGrid('getselectedrowindexes');
       var rowIds = new Array();
       for (var i = 0; i < rowIndexes.length; i++) {
           var currentId = $('#jqxgrid').jqxGrid('getrowid', rowIndexes[i]);
           rowIds.push(currentId);
       };
       $('#jqxgrid').jqxGrid('deleterow', rowIds);
       $('#jqxgrid').jqxGrid('clearselection');
    });

    And this one :

    deleteButton.click(function (event) {
       // get the indexes of the selected rows.
       var selectedrowindexes = $("#jqxgrid").jqxGrid('getselectedrowindexes');
       var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount;
       // begin update. Stops the Grid's rendering.
       $("#jqxgrid").jqxGrid('beginupdate');
       selectedrowindexes.sort();
       // delete the selected rows by using the 'deleterow' method of jqxGrid.
       for (var m = 0; m < selectedrowindexes.length; m++) {
          var selectedrowindex = selectedrowindexes[selectedrowindexes.length - m - 1];
          if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
             var id = $("#jqxgrid").jqxGrid('getrowid', selectedrowindex);
             $("#jqxgrid").jqxGrid('deleterow', id);
          }
       }
       // end update. Resume the Grid's rendering.
       $("#jqxgrid").jqxGrid('endupdate');
    });

    But none of them are working.
    Must I used :

    $("#jqxgrid").bind('rowselect', function (event) {
    var selectedRowIndex = event.args.rowindex;
    });

    ben25
    Participant

    Thanks Peter.
    Can you please give me one example of deleteButton.click(function (event) {delete all selected rows}
    I’m using selectionmode: ‘checkbox’


    ben25
    Participant

    I tried this but it doesn’t help :

    deleteButton.click(function (event) {
     // get the indexes of the selected rows.
    var selectedrowindexes = $("#jqxgrid").jqxGrid('getselectedrowindexes');
    var rowscount = $("#jqxgrid").jqxGrid('getdatainformation').rowscount;
    // begin update. Stops the Grid's rendering.
    $("#jqxgrid").jqxGrid('beginupdate');
    selectedrowindexes.sort();
    // delete the selected rows by using the 'deleterow' method of jqxGrid.
    for (var m = 0; m < selectedrowindexes.length; m++) {
    var selectedrowindex = selectedrowindexes[selectedrowindexes.length - m - 1];
    if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
    var id = $("#jqxgrid").jqxGrid('getrowid', selectedrowindex);
    $("#jqxgrid").jqxGrid('deleterow', id);
    }
    }
    // end update. Resume the Grid's rendering.
    $("#jqxgrid").jqxGrid('endupdate');
    });

    ben25
    Participant

    Hi Peter

    Thank you for your answer I changed getselectedrowindex to getselectedrowindexes but it still doesn’t work.

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