What is the shortest quickest way to get a client side store, that uses some kind of a callback / listener to return data (not from a server). Explained:
Ext.define('aaa.store.ContactList', {
extend: 'Ext.data.Store',
requires: 'aaa.model.ContactList',
model: 'aaa.model.ContactList',
autoLoad: true,
fields:['firstLetter', 'userId', 'userName', 'h', 'w', 'm', 'v', 'custom'],
groupField: 'firstLetter',
sorters: ['firstLetter', 'userId'],
// Overriding the model's default proxy
proxy: {
type: 'direct',
directFn: 'getPhoneBookEntries', <<--- don't want this to be a server method, but a client side js method...
reader: {
type: 'json',
rootProperty: ''
}
}
});
I got a grid using this store to show a contact list. The problem is both 'direct' and other methods rely on the fact that the store reads from a server. but I have my mechanism to read from the server, and I just want to 'feed' the store manually.
Can this be done?
Updating question with some new code:
Model:
Ext.define('WebPhone.model.ContactList', {
extend: 'Ext.data.Model',
fields: [
{ name: 'firstLetter', type: 'string' },
{ name: 'userId', type: 'string' },
{ name: 'userName', type: 'string' },
{ name: 'h', type: 'string' },
{ name: 'w', type: 'string' },
{ name: 'm', type: 'string' },
{ name: 'v', type: 'string' },
{ name: 'custom', type: 'string' }
]
});
Store:
Ext.define('WebPhone.store.ContactList', {
extend: 'Ext.data.Store',
requires: 'WebPhone.model.ContactList',
model: 'WebPhone.model.ContactList',
autoLoad: true,
fields:['firstLetter', 'userId', 'userName', 'h', 'w', 'm', 'v', 'custom'],
groupField: 'firstLetter',
sorters: ['firstLetter', 'userId'],
// Overriding the model's default proxy
// proxy: {
// type: 'memory',
// reader: {
// type: 'json',
// rootProperty: 'root'
// }
// }
});
The gride definition is too long for this post, but it worked with pre-loaded data
Data loading code:
var store = Ext.getStore( "ContactList" );
//var array_values = new Array();
//for( var key in phoneBook )
//array_values.push( phoneBook[key] );
//store.loadData( array_values );
store.loadData( [{firstLetter:'a', userId:'ali', userName:'ali', h:'04040', w:'04040', m:'04040', v:'04040', custom:'04040'}] );
I tried both loadRawData and loadData without success ... Tried with a proxy (ajax/json/memory/array... you name it) and without.
No success. What am I missing here?