Best approach to confirm user before submission from grid


#1

Hi,

I have a DHTMLX grid with a checkbox column. The data is submitted to server using Dataprocessor.
The grid generation code is like this:
mdfgrid = mdfLayout.cells(“a”).attachGrid();
mdfgrid.setHeader(“ID,Core Data Field ,Internal”,null,["",""]);
mdfgrid.setInitWidths(“100,*,50”);
mdfgrid.setColAlign(“left,left,center”);
mdfgrid.setColTypes(“ro,edtxt,ch”);
mdfgrid.setColSorting(“int,str,na”);
mdfgrid.init();
mdfgrid.attachEvent(“onEditCell”,function(stage,id,index,new_value,old_value){
if (stage == 2 && index == 2 ){
console.log("New value "+new_value+“Old Value”+old_value);
return false; //deny edit operation
};
return true;
});

What I’m trying to achieve is that if any user un-checks the checkbox in the third column of the grid in any row, I need to show him a confirmation message and based on user input the value is to be submitted to the server. The above onEditCell triggers for the text column edits as well so I doesn’t suit the purpose(and it gives the checkbox values only for stage 2 and not stage 0 so I cannot cancel the submit and by then the data is already submitted to the server). I see we have an oncheck event but I’m not able to stop the submission of the data by the dataprocessor based on the confirmation dialog
https://docs.dhtmlx.com/api__dhtmlxgrid_oncheck_event.html

Is there a way to achieve this? Basically if the user tries to uncheck the third checkbox column we need to confirm it with a dialog and then if the user clicks yes on that confirm dialog the changed row data can be submitted otherwise the submission is to be cancelled.

Thanks in advance


#2

http://snippet.dhtmlx.com/5/411d655fb
You may try to use the getValue() method to get the current state of the chackbox to validate it and block if it is needed