Despite the COVID-19 outbreak, our team continues operating at full speed. We are always here to support and answer all your questions.

Feel free to reach out by filling this quick form.

Fill the form
Get Free Trial

Having some trouble with updateData

Resolved
Jimmy asked on December 17, 2020

I’m have some trouble with updateData.
When I’m updating a cell on the second level of the grid it works as expected, where the field SecondLevel is empty.
 
If I update a cell on the third level of the grid the value of the cell is not updated but the total is.
In the pictures the green triangles is the fields updated. 
 
I haven’t managed to reproduce it in JSfiddel.
 
Jimmy

5 answers

Public
Jimmy December 17, 2020

I have tied to figure out what is wrong but can’t hope you can help.
 
Forgot the files.
 
Jimmy

Public
Milena Pechura Milena Pechura Flexmonster December 18, 2020

Hello, Jimmy,
 
Thank you for providing your report, screenshots, and functions used to update the data. These files helped us to understand the issue better.
 
We would like to mention that if you want to use the updateData with partial: true, the id field should be specified in your dataset. Updating the data without the id field may have unexpected results.
Our team has prepared steps on how to do the partial update. Please find them below.
 
Firstly, add the id type to the mapping object:

"mapping":{
      "Category": { "type": "string" },
      "Price": { "type": "number" },
      "RowId": { "type": "id" }
      }

Secondly, specify an id field for every object in your dataset:

{
      "Category": "Accessories",
      "Price": 242,   
      "RowId": 1
}

Finally, update the data:

var dataForUpdate = [{
      "Category": "Cars",
      "Price": 51844,
      "RowId": 1   	
}]
flexmonster.updateData({data: dataForUpdate}, {partial: true});

For further details about the updateData API call, please see the following link: https://www.flexmonster.com/api/updatedata/.
 
Please let us know if it helps and if any other questions arise.
 
Best regards,
Milena

Public
Jimmy December 21, 2020

Hey Milena,
I have tried adding the RowId field, but when I update now the cell turns blank if there is already a value in it (see attached hierarchy files).
I actually need to add a new record to the dataset as it’s a delta value in the update statement. so it needs to be added to the existing record insted of replacing it.
 
If I don’t use the use the hierarchy field in the mapping it works as it should, for the purpose I’m using it for (see attached nonHierarchy files).
 
Hope it makes sense what I’m trying to achieve and that you can help.
Jimmy
 

Public
Milena Pechura Milena Pechura Flexmonster December 23, 2020

Hi, Jimmy,
 
Thank you for explaining the issue in detail and for sending the corresponding files.
 
Our team noticed that the RowId specified in the dataset is the same that you use in the updateData function.
As we understand, the desired component behavior is to add a new record to your data. To achieve that, please assign a unique value to RowId in the first parameter of the updateData API call.
We have prepared an example for illustration: http://jsfiddle.net/flexmonster/u384kmhL/.
 
Hope it helps!
Please let us know if it works for you and if any other questions arise.
 
Kind regards,
Milena

Public
Jimmy January 4, 2021

Thanks it’s working now.
 
/Jimmy

Please login or Register to Submit Answer