PDA

View Full Version : Need to re-render grid after slider update



hflipman
7 Jun 2012, 8:39 AM
Hi,

I have a grid with a column that uses a custom renderer. Like:



var cutoff = 0.90;

function renderColumn(val, meta, record){
if (val < cutoff) {
return "is bad";
} else {
return "is good";
}
}


So based on this global cutoff value, the column get rendered one way or the other.

Now my grid is is a panel with a toolbar that has a slider. Like:



Ext.define('Tool.view.Grid', {
extend : 'Ext.grid.Panel',
constructor : function() {
Ext.apply(this, {
...
dockedItems: [{
xtype: 'pagingtoolbar',
store: 'Segment',
dock: 'bottom',
displayInfo: true,
items: [
{
xtype: 'tbseparator'
},
{
xtype : 'slider',
listeners : {
change: function(slider, thumb, newValue, oldValue) {
cutoff = newValue.value / 100;
// var store = Ext.data.StoreManager.lookup('bla');
// store.load();
}
}
}
]
}],
});
this.callParent(arguments);
}
});


So when the slider change,the global cutoff value is set. And at that point I need to re-render the grid.

Re-loading the store works but that leads to an unnecessary server call.

So my question is how does the slider get access to the grid it is in so it can call 'grid.getView().refresh()' or something like that?

Probably a newbie question but any help is appreciated!

Henk

hflipman
7 Jun 2012, 12:04 PM
I can do it with:



listeners : {
change: function(slider, thumb, newValue, oldValue) {
cutoff = newValue.value / 100;
var grid = Ext.getCmp('instanceid');
grid.getView().refresh();
}
}


But now my generic code has a hard-coded component ID in it.

scottmartin
7 Jun 2012, 12:27 PM
But now my generic code has a hard-coded component ID in it.

Use itemId instead of id

Scott.