Announcement
Collapse
No announcement yet.
X
-
You can clear out the data in the DataSource with setCacheData(), but this not automatically cause a ComboBoxItem to re-fetch, just as it would not happen if the data were updated on the server side (what a clientOnly DataSource simulates). Use comboBoxItem.fetchData() to cause a new data fetch.
-
Updating ComboBoxItem optionDataSource
I'm using SmartClient_v121p_2020-04-14_PowerEdition. I have a form with a ComboBoxItem defined, where the ComboBoxItem is backed by a client only DataSource. Upon load of the application, I query the DB and set the data in the DataSource. Example code below:
Code:let comboDS = isc.DataSource.create({ ID: "comboDS", field: [ {name: "id", primaryKey: true}, {name: "item_name"}, {name: "category"} ], dataFormat: "json", clientOnly: true }); let comboForm = isc.DynamicForm.create({ ID: "comboForm", width: "100%", height: 30, fields: [ {name: "selectItem", title: "Select item", defaultValue: defaultID, width: 200, editorType: "ComboBoxItem", completeOnTab: true, addUnknownValues: false, optionDataSource: comboDS, displayField: "item_name", valueField: "id", pickListWidth: 200, autoFetchData: true, changed: function(form, item, value) { // do something here } } ] }); // Get data from DB let comboData = getFromDB(); comboDS.setCacheData(comboData);
Code:let newItem = {id: newID, item_name: newItemName, category: "someCategory"}; comboDS.addData(newItem);
On reset, I tried to set the DataSource's cached data to an empty array to clear the ComboBox. This did not work. Also, when I tried to re-initialize from the DB (same as above), the list also did not update.
Code:comboData.setCacheData([]);
Is this still the case? Is there not a way to modify the optionDataSource at runtime?
Thank you.
Tags: None
Leave a comment: