ParamQuery grid support forum
General Category => Help for ParamQuery Pro => Topic started by: Syreta on June 25, 2018, 12:33:20 pm
-
Hello,
how can I check/uncheck a checkbox within the cellRightClick event?
I tried to update ui.rowData.#checkboxDataIndx# to "true" or "false" and refresh the grid. This works, but the row is not highlighted (like regular check) and when I right click another cell after first cellRightClick, it doesn't work any more.
Is there a correct way to do this?
Thanks,
Syreta
-
Checkbox can be checked programmatically by updatRow() method.
Please try this code
cellRightClick: function(evt, ui){
//debugger;
this.updateRow({
newRow:{state: true},
rowIndx: ui.rowIndx
})
return false; //prevent opening of browser context menu.
},
in this demo
https://paramquery.com/pro/demos/selection_checkbox
-
Thanks for your answer, this works for me! :)
When I update the checkbox of the current row with this code, I want to uncheck all other checkboxes. For this, I found the following code:
$("#grid_table").pqGrid("setSelection", null);
Is it the correct way to do this before updating the current row or is there a better way?
-
Iterate over all rows and set state: true for current row and state: false for other rows
cellRightClick: function(evt, ui){
//debugger;
var rowList = this.option('dataModel.data').map(function(rd, indx){
return {
newRow:{state: (ui.rowData == rd)},
rowIndx: indx
}
})
this.updateRow({ rowList: rowList });
return false; //prevent opening of browser context menu.
},
-
setSelection also works fine.
cellRightClick: function(evt, ui){
//debugger;
this.setSelection(null);
this.setSelection({rowIndx: ui.rowIndx}); //select current row.
return false; //prevent opening of browser context menu.
},