I have a form that depends on an in-memory dataset/datasource. Below is the code used to construct the dataset. I need to programmatically update all values in a column, so that the new values are reflected on the form. JSDataSet.setValue() method doesn’t have any effect on the content of the dataset if a datasource had been obtained from that particular dataset. Could you please tell me if this is supposed the be the case and the rationale for it. I could update the content of the dataset by using a foundset generated from the datasource, but if I do that I get an error shown below. Is there any way to programmatically update values in a column on the form short of constructing another in-memory dataset and creating another form using the solutionModel? I am using Servoy 6.0.2
var columnNames = ["Col1", "Col2", "Col3"];
var dataset = databaseManager.createEmptyDataSet(0, columnNames);
var typeArr = [];
for (idx in columnNames) {
typeArr.push(DM_COLUMNTYPE.TEXT);
}
dataset.addRow(["Val-1-1", "Val-1-2", "Val-1-3"]);
dataset.addRow(["Val-2-1", "Val-2-2", "Val-2-3"]);
dataset.addRow(["Val-3-1", "Val-3-2", "Val-3-3"]);
// when the datasource is created from the dataset, the dataset can no longer be updated using JSDataSet.setValue() method
var datasource = dataset.createDataSource("testDataSet", typeArr);
// this doesn't work
var fs = databaseManager.getFoundSet("testDataSet");
for (var idx = 1; idx <= dataset.getMaxRowIndex(); idx++) {
application.output(dataset.getRowAsArray(idx));
}
for (var idx = 1; idx <= dataset.getMaxColumnIndex(); idx++) {
dataset.setValue(2, idx, "BLAH");
}
for (var idx = 1; idx <= dataset.getMaxRowIndex(); idx++) {
application.output(dataset.getRowAsArray(idx));
}
Cannot create sql: table not found for data source ‘testDataSet’
Wrapped java.lang.RuntimeException: Can’t get new foundset for: testDataSet