Skip to main content

update()

updates properties of the item

update(id: string | number, newItem: object, silent?: boolean): void;

Parameters:

  • id: string | number - the id of the item which needs to be updated
  • newItem: object - a hash of properties which need to be updated
  • silent?: boolean - optional, if set to true, the method will be called without triggering events, false by default
info

Note that after calling the method with the silent:true parameter, you may need to repaint the component with the paint() method.

Example

component.data.update(123, { text:"New text" });

Also note, that for correct work of the method the last update of a data collection should be done with the silent:false setting applied, for example:

const itemsForUpdate = [...]; // items { ... }
const lastIndex = itemsForUpdate.length - 1;

itemsForUpdate.forEach((item, index) => {
data.update(item.id, {
param: "change param",
}, index != lastIndex); // the last update isn't silent, as the `silent:false` parameter is set
});

Related sample: Data. Update