我需要将本地js文件中定义的数据加载到GridPanel的对象中。经过多次尝试,我决定在商店标记中包含一个代理,但现在我收到一个错误,表明" r未定义"我不完全确定这意味着什么,并希望了解一些有助于理解这个错误意味着什么,以及如何解决这个问题。为了帮助您了解我的意思,我在下面包含了一个包含代码的JsFiddle链接。
LoadGridPanelWithLocalJsonDataUsingOnlyExtMarkupAndNativeJavaScript
到目前为止,我还无法使用Ext.fly或Ext.getCmp来持续获取网页上的gridPanel实例或商店对象。我还没有看到数据加载到网格中。在这一点上,我真的很感激一些帮助。
loadGridStoreTestData: function (dataRec) {
var grid = Ext.fly(document.getElementByName("gridPanelClientId"));
if (!grid || grid === 'undefined') {
Ext.fly('errormessage').insertHtml('afterBegin', 'No GridPanel Object found here.');
} else {
Ext.fly('logger').appendChild(document.createTextNode(' 1. gridPanel found. Proceeding to get the Store object.\n'));
grid.on({
'viewready': { fn: this.onViewReadyHandler, scope: this },
'beforeshow': { fn: this.onBeforeShowHandler, scope: this }
//, 'exception': { fn: this.onExceptionHandler, scope: this }
});
var store = grid.getStore();
Ext.fly('logger').appendChild(document.createTextNode('2. gridPanel store accessed.\n'));
if (!store || store === 'undefined') {
Ext.fly('logger').appendChild(document.createTextNode('3. Store not found .\n'));
if (grid.hasChildNodes) {
var children = Array.prototype.slice.call(grid.ChildNodes);
if (children) {
for (var node in children) {
if (typeof (node) === typeof (new Ext.data.Store())) {
store = node;
}
}
}
}
}
if (store) {
store.on({
'datachanged': { fn: this.onStoreDataChangedHandler, scope: this },
'add': { fn: this.onStoreAddHandler, scope: this },
'load': { fn: this.onStoreLoadHandler, scope: this },
'update': { fn: this.onStoreUpdateHandler, scope: this },
'beforefetch': { fn: this.onStoreBeforeFetchHandler, scope: this },
'remove': { fn: this.onStoreRemoveHandler, scope: this },
// 'exception': { fn: this.onStoreExceptionHandler, scope: this },
'clear': { fn: this.onStoreClearHandler, scope: this }
});
grid.store.loadData(dataRec);
}
else {
Ext.fly('errormessage').insertHtml('afterBegin', 'no store configured for the current Grid instance');
}
}
}//,
提前致谢