Author Topic: Delete not working under grouping  (Read 2026 times)

EPM Solutions

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 182
    • View Profile
Delete not working under grouping
« on: October 13, 2017, 02:54:59 pm »
Hello Support Team,

I try to delete row under grouping but not able to delete.

Here is example my code:
var myGrid = this;
 
$cell.find("button").button({
    icons: {
      primary: 'ui-icon-scissors'
    }
  })
  .bind("click", function() {
    var ans = window.confirm("Are you sure to delete?");
    if (ans) {
      myGrid.deleteRow({
        rowIndx: rowIndx
      });
    }
  });


and also try with below code:
$cell.find("button").button({
    icons: {
      primary: 'ui-icon-scissors'
    }
  })
  .bind("click", function() {
    var group = $("#grid").pqGrid("Group");
    group.removeGroup('Project_tx');
    var ans = window.confirm("Are you sure to delete?");
    if (ans) {
      myGrid.deleteRow({
        rowIndx: rowIndx
      });
      group.addGroup('myGrpColumn');
    } else {
      group.addGroup('myGrpColumn');
    }
  });

In the second code the row id is not current because after remove the grouping the row index is changed.

Please find below screen shot for giving you some idea about my requirement.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Delete not working under grouping
« Reply #1 on: October 16, 2017, 11:09:12 am »
You can get new value of rowIndx from ui.rowData as rowData doesn't change with grouping on/off.

Code: [Select]
render: function (ui) {
return "<button type='button' class='delete_btn'>Delete</button>";
},
postRender: function (ui) {
var grid = this,
$cell = grid.getCell(ui);
$cell.find(".delete_btn")
.button({ icons: { primary: 'ui-icon-scissors'} })
.bind("click", function (evt) {
//turn off grouping.
grid.Group().option({on: false});
grid.deleteRow({
//get fresh rowIndx from rowData
rowIndx: grid.getRowIndx({rowData: ui.rowData }).rowIndx
});
//turn on grouping.
grid.Group().option({on: true});
});
}

please note that this approach is not compatible with batch editing.

The only way I can see it work is to use Row editing: add / edit/ delete one row at a time, save the changes and purge the transaction history.

https://paramquery.com/pro/demos/editing

EPM Solutions

  • Pro Ultimate
  • Full Member
  • *
  • Posts: 182
    • View Profile
Re: Delete not working under grouping
« Reply #2 on: October 16, 2017, 11:31:58 am »
Hello Support Team,

Thanks for your response, i tried with given solution and it working fine.


 :) :D :D :D :D :) :) :)