Problem refreshing my grid after insertion, updated deleted

Hello everyone, I have a problem with my grid refresh after insertion, modification and updating.

I use the method clearAll (), the grid is refreshed but the data is not updated, i must refresh the page to update data.

Here is the function that displays my grid

function afficheGrille()
			{
				grid = new dhtmlXGridObject('gridbox');
				grid.setImagePath("vue/dhtmlxGrid/codebase/imgs/");
				grid.setHeader("nom,iscurrent,islocked,debut,fin");
				grid.attachHeader("#text_filter");
				grid.setInitWidths("200%,200%,200%,200%,200%");
				grid.setColSorting("connector");
				grid.setSkin("dhx_skyblue");			
				grid.init();			
				grid.attachEvent("onRowSelect", function(rID){
					//formannee.load("controleurs/modifierAnnee.php?id="+rID,cInd);
					myVar = rID;
				})
				dp = new dataProcessor("controleurs/supprimerAnnee.php");								
				dp.init(grid);
				grid.clearAll();
				grid.load("controleurs/annee.php");	
			}

And Here is the function update, delete insert.

function doOnLoadbtnannee() 
			{
				btnannee = new dhtmlXForm("btnannee", btnformData);
				// ceci est l'ensemble des évènements qui agit sur les boutons du formulaire année
				btnannee.attachEvent("onButtonClick", function(name, command)
					{
						if(name=="modifier")
					    {	
							if(grid.getSelectedId() != null)
							{
								dhxWins = new dhtmlXWindows();
								modalUpdateAnnee = dhxWins.createWindow(1, 550, 250, 450, 350);
								modalUpdateAnnee.setText("Modification année budgétaire");
								formannee = modalUpdateAnnee.attachForm(structformannee);	
								formannee.load("controleurs/modifierAnnee.php?id="+myVar);
								var dp2 = new dataProcessor("controleurs/annee.php");
								dp2.init(formannee);	
								formannee.setItemValue("idcache",myVar);
								// ceci est l\évènement qui agit sur le bouton engistrer du formulaire année
								formannee.attachEvent("onButtonClick", function(name, command)
									{
										if(name=="enregistrer")
										{
											formannee.save();
											modalUpdateAnnee.close();											
											grid.load("controleurs/annee.php");
											grid.clearAll();											
										}
									}
								);
							}
							else alert("Veuillez selectionner une ligne!")
						}else 
						  if(name=="supprimer")
						 {
							grid.load("controleurs/supprimerAnnee.php?id="+myVar);
							grid.clearAll();
							//grid.deleteSelectedRows();
						 }else 
						 if(name=="cloturer")
						 {
							grid.load("controleurs/cloturerAnnee.php?id="+myVar);
							grid.clearAll();
						 }else 
						 if(name=="encours")
						 {
							grid.load("controleurs/encoursAnnee.php?id="+myVar);
							grid.clearAll();
							//alert("Opération éffectuée avec succès");
						 }
						if(name=="nouveau")
						 {
							{
								dhxWins = new dhtmlXWindows();
								modalNewAnnee = dhxWins.createWindow(1, 550, 250, 450, 350);
								modalNewAnnee.setText("Modification année budgétaire");
								formannee = modalNewAnnee.attachForm(structformannee);
								var dpp = new dataProcessor("controleurs/annee.php");
								dpp.init(formannee);	
								// ceci est l\évènement qui agit sur le bouton engistrer du formulaire année
								formannee.attachEvent("onButtonClick", function(name, command)
									{
										if(name=="enregistrer")
										{
											formannee.save();
											modalNewAnnee.close();
											grid.clearAll();
										}
									}
								);
							}
						 }
					}
				);
			}

Thank you for bringing me a little help

a) if you have configured connector correctly - there is no need to force data reloading, as data will be updated in the grid after update correctly after data saving by dataprocessor.

b) correct order of commands is

grid.clearAll(); grid.load("controleurs/annee.php");

Clearing first, and loading only after it.

thank you,
but this is what I did

dpDetailbudget = new dataProcessor("controleurs/supprimerDetailBudget.php");								
					dpDetailbudget.init(gridDetailBudget);
					gridDetailBudget.clearAll();
					gridDetailBudget.load("controleurs/s_Detailbudget.php");

and the data are not always updated after operations add, edit, delete.

and the data are not always updated after operations add, edit, delete.

Is data not updated on server side or on client side after reloading ?

There are two possible caveats with clearAll
If you are calling it from some event like onEventAdded | onEventChanged - it may load data before it really saved, as data saving request is sent in the same time ( you can use onAfterUpdate event of dataprocessor, at which time data is updated in DB for sure )

Also, in some cases it possible that client caches server side response. You can try to randomize url like next, to prevent caching

gridDetailBudget.load("controleurs/s_Detailbudget.php?uid="+(new Date()).valueOf());

I’ve had the same problem even with trying to randomize the url; what I found that actually fixed the problem was to perform a function as follows in order to load the updated xml:

setTimeout(function() {

gridDetailBudget.load(“controleurs/s_Detailbudget.php”);

},100);

This slight delay 100 milliseconds or whatever you want to set it to, gave the server enough time to process and update with the correct data.

Thank you, I’ll try and get back to you.