Hello!
I need a dynamic json configurable column grid. I made one outside my project, what is the good way to insert it to MVC architecture?
This is the code:
PHP Code:
Ext.Ajax.request({
url: 'data/cd-dashboard.json',
success: function(response){
var object = Ext.decode(response.responseText, false);
var columnsFromServer = object.columns;
var columns = [];
var fields = [];
Ext.each(columnsFromServer, function(column){
fields.push(column.dataIndex);
});
Ext.define('MYAPP.model.User', {
extend: 'Ext.data.Model',
fields: fields
});
Ext.define('MYAPP.view.general.DynamicColumnsGrid', {
extend: 'Ext.grid.Panel',
alias: 'widget.dynamiccolumnsgrid',
requires: [
'Ext.grid.column.Action',
'Ext.toolbar.Paging'
],
initComponent: function() {
var me = this;
this.store = {
fields: columnsFromServer,
model: 'MYAPP.model.User',
storeId: 'dashboard',
id: 'dashboard',
autoLoad: true,
remoteSort: true,
sorters: [
{
property : 'organization',
direction: 'DESC'
} ],
proxy: {
type: 'ajax',
url: 'data/users.json',
reader: {
type: 'json',
root: 'data',
successProperty: 'success'
}
}
};
this.columns = columnsFromServer;
Ext.apply(this, {
bbar: {
xtype: 'pagingtoolbar',
store: this.store,
displayInfo: true
}
});
this.callParent(arguments);
}
});
}
});