I have two controls using the same dataSource instance. One grid allows users to add/edit/delete accounts. Another tab has a grid for editing users, but also has a control to select the account that the user is associated with. It seems that one of the controls will always show the list, but the other shows the “loading data” icon. I reproduced it like this:
Commenting out the dataSource property from either control allows the other to display the list. Having both results in one showing the “loading data” prompt. Any suggestions?
Thank you for the suggestion. I tried that but it resulted in exactly the same behavior. If the select uses the same dataSource, the ListGrid displays only the loading data indication, but does not refresh when the data arrives. If I switch the order in which the controls are instantiated, then they reverse–the other shows the data but one still does not.
Setting the grid autoFetchData to false, then when the fetch event fires on the dataSource doing grid.fetchData() worked. But it does not seem like this workaround should be necessary.
Here is a portion of the code. The dataSource is a “private” variable inside an outer class which accepts an adapter instance to perform the actual queries (there is an adapter for each type of query). I’m showing just the fetch operation. The events being dispatched are just so that views outside of the databound views/grid can respond to the various data events.
ipas.data.DataSource = function(adapter) {
var that = this;
var eventListeners = [];
// ....
var dataSource = isc.DataSource.create({
dataProtocol: "clientCustom",
dataFormat: "custom",
fields: adapter.getKeys(),
transformRequest: function (request) {
var action = request.operationType;
var response; // DSResponse passed to processResponse
var event; // data event to dispatch
trace("transformRequest for operation [" + action + "]");
if (action === "fetch") {
adapter.performFetch(request, function(code, results, total) {
if (total == undefined) total = 0;
trace("results complete: " + code);
if (code > 299 || code == 0) {
response = isc.DSResponse.create({
status: -1
});
}
else {
updateTotalDataRecords(total);
trace("total records is " + totalDataRecords);
response = isc.DSResponse.create({
status: 0,
data: results,
totalRows: totalDataRecords
});
dispatchEvent(new ipas.Event({
type: ipas.FETCH_EVENT,
total: totalDataRecords
}));
}
trace("invoking processResponse for fetch");
dataSource.processResponse(request.requestId, response);
trace("processResponse complete");
});
}
else if (action == "add") {
I also modified the above to include clientContext from the request in the response objects created. Thought they may have been needed by the databound controls, but it didn’t seem to matter.
Is something missing with regards to these dataSources? In all cases where this occurs, DataSource.processResponse() is invoked with the DSResponse created as shown above.