/*
12. List all the potential issues with the following Ext JS 4 plugin definition:
Ext.define('MyGridPlugin', {
init : function(grid) {
grid.getStore().on({
load : function() {
grid.el.highlight(); // Some cool fx to bring attention to the grid
}
});
}
});
// Let’s try it out
var myGrid = new Ext.grid.Panel({
renderTo : document.body,
store : someStore,
plugins : new MyGridPlugin()
});
someStore.load();
*/
// ANSWER:
// 1. The store can be loaded before the grid component is rendered. In this case there is no el property and it can be an issue.
Ext.define('MyGridPlugin', {
init : function(grid) {
grid.getStore().on({
datachanged : function() {
grid.el && grid.el.highlight(); // Some cool fx to bring attention to the grid <-------
}
});
}
});
// Let’s try it out
someStore = Ext.create('Ext.data.Store', {
fields: [{name: 'name'}]
});
var myGrid = Ext.create('Ext.grid.Panel', {
//renderTo : Ext.getBody(),
store : someStore,
plugins : [
Ext.create('MyGridPlugin')
],
columns: [{
text: 'Name',
dataIndex: 'name'
}]
});
someStore.loadData([
{ name: 'C' },
{ name: 'D' }
]);
myGrid.render(Ext.getBody());
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.