PDA

View Full Version : plugin and datastore



oturkan
11 Feb 2014, 6:01 AM
Hi I create datasource with in plugin.


Ext.define('Ext.ux.DataSource', {
extend: 'Ext.AbstractPlugin',
alias: 'plugin.datasource',


component: null,


init: function (obj) {
var me = this;
component = obj;
component.store = new Ext.data.Store({
pageSize: 50,
proxy: {
type: 'ajax',
url: 'search.aspx',
reader: {
root: 'rows',
totalProperty: 'totalCount'
}
},
fields: [
{ type: 'int', name: 'Id' },
{ type: 'string', name: 'FirstName' },
{ type: 'string', name: 'LastName' },
{ type: 'date', name: 'BirthDate' },
{ type: 'string', name: 'Gender' },
{ type: 'string', name: 'Note' },
],
idProperty: 'Id'
});


component.store.remoteFilter = true;


if (!component.store.proxy.hasOwnProperty('filterParam')) {
component.store.proxy.filterParam = 'control';
}


component.store.proxy.encodeFilters = function (filters) {
return filters[0].value;
}


component.runQuery = this.runQuery.bind(component);
},


runQuery: function (controls) {
component.store.filter({
id: 'control',
property: 'control',
value: Ext.encode(controls)
});
}
});



when i use plugin on grid search.aspx work great. but store data items is empty. what can i do

oturkan
12 Feb 2014, 6:53 AM
i found the solution on init



init: function (component) {
var me = this;
var store = new Ext.data.Store({
pageSize: 50,
proxy: {
type: 'ajax',
url: 'search.aspx',
reader: {
root: 'rows',
totalProperty: 'totalCount'
}
},
fields: [
{ type: 'int', name: 'Id' },
{ type: 'string', name: 'FirstName' },
{ type: 'string', name: 'LastName' },
{ type: 'date', name: 'BirthDate' },
{ type: 'string', name: 'Gender' },
{ type: 'string', name: 'Note' },
],
idProperty: 'Id'
});


store.remoteFilter = true;


if (!store.proxy.hasOwnProperty('filterParam')) {
store.proxy.filterParam = 'control';
}


store.proxy.encodeFilters = function (filters) {
return filters[0].value;
}


component.reconfigure(store);
component.runQuery = this.runQuery.bind(component);
},

Gary Schlosberg
12 Feb 2014, 10:12 AM
Glad you found a solution, and thanks for sharing it with the community.

oturkan
12 Feb 2014, 11:36 AM
if component is a grid "reconfigure" works greats but if component is a panel (if you want to use store on panel for extend component) there is no reconfigure method. Any idea ?