After long searches, I succeed to delete a row in a jqgrid with form editing.
But, there are two little things left :
- How to reload the grid with the row deleted ?
- If the row can't be deleted, how to display the information and the reason why ?
I tried to search in the arguments passed to the function in the event "afterSubmit", but there is no real explanations about how to manipulate these arguments.
The creation of the grid :
tableToGrid("#TabUser", {
caption: 'Gestion des Utilisateurs',
width: 'auto',
height: "auto",
hidegrid: false,
pager:'#DivUser',
rowNum:10,
cellEdit: true,
cellsubmit: 'remote',
cellurl: 'Adminuser',
colModel: [{name:'Id', editable:false, width:50},
{name:'Login', editable:false, width:150},
{name:'Nom', editable:true, width:200},
{name:'Prénom', editable:true, width:200},
{name:'Rôle', editable:true, width:80, edittype:'select',
editoptions: { multiple: false, value:{ADMIN:'ADMIN',GUEST:'GUEST'}}},
{name:'Email', editable:true, width:200}],
beforeSubmitCell: function(rowid, celname, value, iRow, iCol) {
var rowData = jQuery(this).getRowData(rowid);
var idUser= rowData['Id'];// On récupère l'Id du user en cours d'édition
return {idUser:idUser}; }
});
The navigation :
$("#TabUser").navGrid('#DivUser',
{edit:false,add:false,del:true,search:false},{}, {},
{width:500, url:'Adminuser',
reloadAfterSubmit:true,
onclickSubmit: function(param){
var sr = jQuery('#TabUser').getGridParam('selrow');
var idUser = jQuery('#TabUser').getCell(sr,'Id');
return {idUser:idUser}; },
afterSubmit: function(reponse, data) {
$("#TabUser").trigger('reloadGrid');
$("#eData").click(); // clic sur "Annuler"
return [true,"Supression réussie"];
}
});
What are the values of "response" and "data" ? How to reload the grid ?
The row is effectively deleted in the database with the url 'Adminuser' (written in java).