PDA

View Full Version : Passing options to grid features



RoyalSens
6 Jun 2014, 4:36 AM
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:


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:


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


return config;


Has anybody a clue how to fix this?

Code snippet of the feature...


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,,,
});
}
});

RoyalSens
12 Jun 2014, 12:25 AM
Nobody knows how to pass parameters to a feature? I cannot find it in the documentation.