dhtmlxgrid dataprocessor save updated rows w/o page refresh

Hi,

In my grid I have 10 rows, the value in 1-9 rows - 2nd column, when modified, updates the value in 10th row’s 2nd column(i.e. the value adds up).

The issue which I am facing is, after data is modified in first place, lets say for 1st,2nd & 3rd row, 10th row is updated as well with the total value, status being set to updated and data for the 4 rows, i.e. 1,2,3 & 10 are saved to db successfully, thereafter, when i again modify other rows(without refreshing the page or loading the updated data from db), i.e. 4,5,6,7,8 & 9 the total value gets updated in 10th row of the grid on the page, however when I save the data to db then 10th row data does not gets updated.

I did try printing the (row)ids and it did not show 10th row id during second save.

The status of 10th row is being set as below in doCalc function:-

myDataProcessor.setUpdated(10,true,“updated”);

Saving data to db is done using below lines of code:-

function save(){
myDataProcessor.sendData();
return true;
}

the grid initialization code is as below:-

mygrid = new dhtmlXGridObject(‘gridbox’);
myDataProcessor = new dataProcessor(“myAction.java”);
myDataProcessor.setTransactionMode(“POST”,true);
myDataProcessor.setUpdateMode(“on”);
myDataProcessor.init(mygrid);

If anyone can provide some way such that same row can be saved second time without refreshing the page.

I also tried the following code in my save function, i.e. after dataprocessor sends the data to db set the updated status of all rows to false, but it did not help except setting the text to normal, from bold :-

function save(){
myDataProcessor.sendData();

var rows = mygrid.getRowsNum();
for (var i = 0; i < chngIds; i++) {
myDataProcessor.setUpdated(i+1,false);
}
return true;
}

Thanks in advance.

Steve

Can someone help me on the above issue? Thanks…!!!

Unfortunately the issue cannot be reconstructed locally. Please make sure that you set row as updated after the changing the value of the cell by API.

If issue still occurs - please, provide a more complete sample of your code to see the mechanism of the created functionality.

Hi sematik,

Please find my complete code attached as below:-

JSP Code:–

doOnCellEdit(stage, rId, cInd, nValue, oValue) {
var amt = null;
var amtColumn = 2;
var catAmt = “”;
var catAmtAddToVal = 0.0;
if ((stage == 2) && (oValue != nValue) && (nValue!="")) {

		var diff = nValue-oValue; // get the differnce between new value and old value 
		 catAmt = parseInt(diff);
		
		var mainCatVal = mygrid.cells2(rId-1, 1).getValue().toString();(the first row of the grid starts from 1 and 1 is the MainCategory column index)
		 var rows = mygrid.getRowsNum();// get total number of rows
		 
		  outerloop:
		  for (var i = 0; i < rows; i++) {// loop through each row to find the exact row matching the sub category to main category value
		 	var subCatVal = mygrid.cells2(i, 0).getValue().toString(); 
		 	 
		 	 if (subCatVal==mainCatVal) { // when found
		 							
		 	      var addToSubCatAmt = mygrid.cells2(i, cInd).getValue().toString();
		 	      catAmtAddToVal = parseInt(addToSubCatAmt);
		 	      var sum = catAmtAddToVal+catAmt;
			      
			      mygrid.cells2(i, cInd).setValue(_sum);
			      
			      myDataProcessor.setUpdated(i+1,true,"updated");
			      
			      var mainCategoryAddToVal = mygrid.cells2(i, 1).getValue().toString();
		 		 if((mainCategoryAddToVal!=null) || (mainCategoryAddToVal!="")){
		 			 mainCatVal = mygrid.cells2(i, 1).getValue().toString();
		 			 continue outerloop;
		 		 }
		 	   }
		 }
} 

return true;

}

Now in my java class, at the first time of save I get all the row ids which were updated on the jsp page as below:-

String _ids = request.getParameter(“ids”);
System.out.println(“ids==”+_ids);

At the second time of save, though the rows are being updated by the cell API (Note: I confirmed it by adding dhtmlx/dhtmlxDataProcessor/codebase/dhtmlxdataprocessor_debug.js & /dhtmlx/dhtmlxDataProcessor/codebase/dhtmlxdataprocessor_deprecated.js on my jsp page and the all the ids showed up in the window which were updated at the second time too), however in my action class only the ids which were not in the first save request gets printed.

For instance, as i said I have 10 rows, rows 1-4 adds up to row number 5(i.e. for subCatogery 1-4 MainCategory column has value 5) & from rows 5-7 adds up to 8(i.e. for subCatogery 5-7 MainCategory column has value 8). In addition, rows 8-9 adds up to 10(i.e. for subCatogery 8-9 MainCategory column has value 10).

Now at the first time I changed the value of, lets say 2nd row’s amount column, so the value of 5th,8th and 10th rows gets updated marking the row as updated, thereafter saving to the database. No issue till this point.

Second time, the value of, lets say I changed the value of 6th row so the value of 8th and 10th rows gets updated marking the row as updated and the dataprocesor debugger shows the value of 6th, 8th & 10th rows as being marked [updated,valid], however in my java class only id which is printed is 6.

So the ids are not being sent, during second save request, to my java class which are already been sent in the first save request. This issue is resolved if the page is refreshed, however I want to avoid page refresh and send the corrected row ids with the updated values to db.

Please help…

Thanks,
Steve

Hi Support/Sematik,

Did anyone get to reproduce this issue.?

It’s really time consuming when you have a big data set loaded to the grid, thereafter you have to refresh the page after editing cell value & save. I know editing all rows and saving in end works, but what if the user saves it after editing and then he has to edit the grid data again without refreshing/reloading the page?

Thanks in advance…

SteveM

Unfortunately the issue cannot be reconstructed.
Please, provide the needed conditions of data and exact steps to reproduce the issue.

Hi Sematik,

Thanks for your patience and replying to my issue.

I will try to put the questions in a simple way.

At the first time, If my grid has 10 rows and user updated all the rows and clicked save. All the row ids(with row data is sent to the server).

However, second time without page refresh or reloading the grid, when all the rows are updated again and I click save why all the row ids with row data is not sent to the server?

To summarize, how can I send updated rows everytime to the server without refreshing the page? Please suggest.

I am sure this is an issue and you can reproduce this issue by any piece of code you have. BTW, I am using jsp and oracle.

Thanks,
Steve

Unfortunately the issue cannot be reconstructed. With your code data updates well all the time.
Also, please, have a look at the following working example:
dhtmlx.com/docs/products/dht … _once.html

Hi Sematik,

Apologies for providing incorrect description.

Yes, you are right if all the rows are updated(manually), are sent to server.

Coming back to my previous question, i.e. if an user updates the 1st row, simultaneously other (4)rows also gets updated via js method, though the user has only updated the first row manually. In this case, when save/update is clicked, I agree, all updated row ids (i.e. 1-4 with row data) is sent to server.

However, second time without page refresh or reloading the grid, when 2nd row is updated manually by the user, simultaneously other rows, i.e. 3rd & 4th, are also updated via js method. In this case, when save/update is clicked, only 2nd row is being sent to the server while 3rd & 4th rows are not.

Therefore, when 3rd & 4th rows are saved in the first place, are not sent again second time. Which also means that only manually updated rows are sent to the server second time, i.e. 2nd row.

Do you have any sample which demonstrates and proves that my observation is not right?

Thanks,
Steve

Your issue still cannot be reconstructed locally.
Please, provide open ticket at support.dhtmlx.com and provide a complete demo or a demo link where the issue can be reconstructed.
Here is the tutorial how to create a complete demo:
docs.dhtmlx.com/doku.php?id=othe … leted_demo