rest - How to create mock data in store proxy of ExtJS -
here code data using rest api
, rest api return array of objects
items = [ {id: 1, group: group1}, {id: 1, group: group2} ]
but while waiting rest api(url: '/api/group') want mock data can continue task don't know how. there anyway can have items in proxy instead of url now. appreciated
ext.define('console.store.groups', { extend: 'ext.data.store', model: 'console.model.group', autosync: false, buffered: false, pagesize: 1000, autoload: false, autodestory: true, purgepagecount: 3, sorters:[{ property:'name', }], trailingbufferzone: 100, proxy: { simplesortmode: true, type: 'rest', url: '/api/groups', reader: { type: 'json', root: 'data', totalproperty: 'total' } } });
using memory proxy worked in case. below code using memory proxy how make post(add new group), put(update group), delete(remove group) work memory proxy.
below code use memory proxy instead of url (rest api).
var data = [ {id: 1, group: group1}, {id: 1, group: group2} ]; ext.define('console.store.ldapgroups', { extend: 'ext.data.store', model: 'console.model.ldapgroup', autosync: false, buffered: false, pagesize: 1000, autoload: false, autodestory: true, purgepagecount: 3, sorters:[{ property:'label', }], trailingbufferzone: 100, proxy: { type: 'memory', enablepaging: true, data: data, reader: { type: 'array' } } // proxy: { // simplesortmode: true, // type: 'rest', // url: '/api/groups', // reader: { // type: 'json', // root: 'data', // totalproperty: 'total' // } // } });
Comments
Post a Comment