I’ll step back to give you more details about what i’m trying to obtain. (I’m using Smartclient 7.0 beta LGPL).
Previously I was initializing the ListGrid “listaPeriodi” like this:
fetchPeriodi = function (record) {
periodiDS.fetchData(
{ nudoss: record.nudoss },
function (response, data, request) {
listaPeriodi.setData(data);
}
);
}
the datasource is defined as:
listaPeriodi = isc.ListGridScelta.create({
ID: "listaPeriodi",
dataSource: "periodiDS",
selectionChanged: "periodi.listaPeriodiChangeSelection(record, state)",
fields: [{name: "periodo", title: "Periodo di Budget"},
{name: "stato", title: "Stato"},
{name: "idPeriodo", showIf: "false"}]
});
This way, when the “nudoss” criteria changes, data is retrieved from server only the first time for every criteria value, otherwise the cached data is used.
And I understand that this is the intended behaviour.
now I want to retrieve data from server every time.
Correct me if I’m wrong, but I understand that I must invalidate the cache, and to call the invalidateCache method I need a ResultSet object.
With the line commented as “doesn’t work”, I saw no differences, there is a request to the server, but the “nudoss” parameter isn’t available.
my most recent attempt is:
fetchPeriodi = function (record) {
var data = periodi.listaPeriodi.getData();
if (isc.isA.ResultSet(data)) {
data.setCriteria({ nudoss: record.nudoss });
data.invalidateCache();
} else {
periodiDS.fetchData(
{ nudoss: record.nudoss },
function (response, data, request) {
var rs = isc.ResultSet.create({
dataSource: "periodiDS",
criteria: { nudoss: record.nudoss },
useClientFiltering: false
});
listaPeriodi.setData(rs);
}
);
}
};
but it doesn’t work as I need, cached data is used after the first fetch (per every nudoss value).
Have you got a working example where I can clear my understanding?
Or a link to the docs?