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:
This works as designed. I have a use case where the user can add another "item" in another part of the application. When this item gets successfully saved to the DB, I do the following, so that the user has the option to select that item and view details of it at a later time:
This too works great. Note that I am obfuscating what the application actually does per my company policy, so what come next may not make sense, but it's a valid use case in this application. The use case is that the system behind the application can get "reset". When this happens, I need to clear out all of the "items" from the drop down list. Once the reset is complete, I need to re-initialize from the DB, at which point all of the "new items" that were added would not be there, so would need to be removed from the ComboBox.
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.
I read a post from 2012 in the forum that basically said that "Select items do not fully support having their optionDataSource modified at runtime....". https://forums.smartclient.com/forum...election-issue
Is this still the case? Is there not a way to modify the optionDataSource at runtime?
Thank you.
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.
Comment