zachHurt
21 Jun 2012, 6:26 AM
Hello,
I am evaluating the EXTJS4 framework currently and have been playing around with Architect quite a bit. I am developing software that needs to be able to dynamically read in data to a grid. Now I have the gird switching the url of the proxy of the store but that only appears to work if the files associate with the same model. How do I go about changing the grids's associated model so it will work.
I started using a simple controller to listen for button clicks (my prototype only has one button) and I have it switching the store but can't get much further than that.
Ext.define('MyApp.controller.MyController', {
extend: 'Ext.app.Controller',
views: [
'MainPanel'
],
refs: [
{
ref: 'MainPanel',
selector: '#mainPanel'
},
{
ref: 'grid',
selector: '#grid'
},
{
ref: 'CarDataStore',
selector: '#carDataStore'
}
],
onButtonClick: function(button, e, options) {
var grid = this.getGrid();
var store = Ext.getStore('CarDataStore');
var model = Ext.ModelManager.getModel('MyApp.model.CarDataModel');
//console.log(grid);
//console.log(store);
//grid.store.removeAll();
//grid.store = store;
//console.log(grid.store);
//grid.store.sync();
grid.bindStore(store);
//grid.dataIndex = grid.store.model.getName();
//grid.autoColumns();
grid.update();
//console.log(grid.store);
function columnAlignment(){
var column1 = grid.columns[0];
console.log(model);
console.log(column1);
// console.log(grid.store.model);
}
columnAlignment();
console.log(grid);
//console.log(grid.dataIndex);
},
init: function() {
this.control({
"button": {
click: this.onButtonClick
}
});
}
});
PS, I know my code is terrible. I am just an intern
I am evaluating the EXTJS4 framework currently and have been playing around with Architect quite a bit. I am developing software that needs to be able to dynamically read in data to a grid. Now I have the gird switching the url of the proxy of the store but that only appears to work if the files associate with the same model. How do I go about changing the grids's associated model so it will work.
I started using a simple controller to listen for button clicks (my prototype only has one button) and I have it switching the store but can't get much further than that.
Ext.define('MyApp.controller.MyController', {
extend: 'Ext.app.Controller',
views: [
'MainPanel'
],
refs: [
{
ref: 'MainPanel',
selector: '#mainPanel'
},
{
ref: 'grid',
selector: '#grid'
},
{
ref: 'CarDataStore',
selector: '#carDataStore'
}
],
onButtonClick: function(button, e, options) {
var grid = this.getGrid();
var store = Ext.getStore('CarDataStore');
var model = Ext.ModelManager.getModel('MyApp.model.CarDataModel');
//console.log(grid);
//console.log(store);
//grid.store.removeAll();
//grid.store = store;
//console.log(grid.store);
//grid.store.sync();
grid.bindStore(store);
//grid.dataIndex = grid.store.model.getName();
//grid.autoColumns();
grid.update();
//console.log(grid.store);
function columnAlignment(){
var column1 = grid.columns[0];
console.log(model);
console.log(column1);
// console.log(grid.store.model);
}
columnAlignment();
console.log(grid);
//console.log(grid.dataIndex);
},
init: function() {
this.control({
"button": {
click: this.onButtonClick
}
});
}
});
PS, I know my code is terrible. I am just an intern