Wijmo DataView objects provide a number of functions that allow you to edit data locally (client side), and the BreezeDataView object allows you to update remote datasources. Useful functions for editing data with the wijmo.data namespace include the following.
This function takes an object as a parameter.
Example |
Copy Code |
---|---|
dataview.add({ ID: 6, Name: "Item6", Value: "Test 6" }); |
Pass an element of the dataview to this function to indicate which element to remove. If no element is specified, it removes the currently selected element by default.
To remove the first element of the dataview |
Copy Code |
---|---|
dataview.remove(dataview.local[0]); |
This function updates the value for the specified property of the record.
It takes three parameters:
The following example assumes a ‘Value’ property in the record.
To update the Value property of the first element |
Copy Code |
---|---|
dataview.setProperty(0, "Value", "Updated value"); |
The editItem function takes an element of the dataview as a parameter.
Example |
Copy Code |
---|---|
dataview.editItem(dataview.local[0]); |
This function is not used to update the element of the dataview. It just marks that the element is in edit state, and stores the original element in the cache. If you cancel the update, the element rolls back to the element stored in the cache.
It is important to invoke this function before invoking the setProperty function.
It is not necessary to invoke this function before invoking the add function, since the added item is marked as being in edit state and stored in cache in the add function.
This function takes no parameters. Use it to roll back the latest update to the dataview.
Example |
Copy Code |
---|---|
dataview.cancelEdit(); |
Note: cancelEdit rolls back changes made using the add and setProperty functions, but currently does not roll back changes made using the remove function.