vendredi 6 juin 2014

Passing options to grid features

I'm trying to create a custom grid feature, that shows an empty row (placeholder row) to directly add new records to the store. I have this working, but I want to be able to pass options to this grid feature. Normally you add the feature on the grid as follows:


Code:



Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: Ext.data.StoreManager.lookup('simpsonsStore'),
columns: [
{ text: 'Name', dataIndex: 'name' },
{ text: 'Email', dataIndex: 'email', flex: 1 },
{ text: 'Phone', dataIndex: 'phone' }
],
features = [{
option1: false,
placeholderDefaults: {
amount: 10
},
ftype: 'placeholderrow'
}],
height: 200,
width: 400,
renderTo: Ext.getBody()
});

However, the options (option1 and placeholderDefaults) are not available within the feature. And it looks like that other feature do get their parameters this way. Maybe it is because I use Sencha Architect? Because I add the feature via the 'Process config' option. And then settings the config:


Code:



config.features = [{
option1: false,
placeholderDefaults: {
amount: 10
},
ftype: 'placeholderrow'
}];


return config;

Has anybody a clue how to fix this?

Code snippet of the feature...



Code:



Ext.define('Ext.grid.feature.PlaceholderRow', {
alias: 'feature.placeholderrow',

init: function(grid) {
var me = this,
store = grid.getStore(),
view = me.view;
/* option1 and placeholderDefaults are not available here! */
view.on({
beforerefresh: function(view) {
// Code to add a placeholder row into the store,,,
});
}
});




Aucun commentaire:

Enregistrer un commentaire