PDA

View Full Version : Profile RowAction



foxmarco
29 Dec 2011, 3:29 AM
The main idea is load the actions of a RowAction pluing only if the current user could use.
Before render the RowAction column an Ajax call is execute and the internal actions buttons are reloaded on user profile.




Ext.define('Ext.ux.grid.ProfileRowActions',{
extend:'Ext.ux.grid.RowActions',
alias:'widget.profilerowaction',

idBar : null,
aliasBar : null

,initComponent : function(){
var me = this;
me.fields = me.fields || ['id'];
me.store = this.buildStore();
me.store.load();
me.callParent(arguments);
me.hidden = true;
}

/**
* Init store to load items from DB
*/
,buildStore : function() {
this.store = Ext.create("Ext.data.Store", {
type : 'json',
fields : this.fields,
proxy : {
type : 'ajax',
url : this.url,
extraParams : {id: this.idBar, aliasBar: this.aliasBar},
reader : {
type : 'json',
root : 'data'
}
},
listeners: {
'load': this.onLoad,
scope: this
}
});
return this.store;
}

,onLoad : function(localStore, records) {
var me = this;
var remoteActs = [];
Ext.each(me.internalActions, function(a, i) {
Ext.each(records, function(ra, j) {
if (a.id == ra.data.id) remoteActs.push(a);
});
});
//swap actions profile
me.actions = remoteActs;
me.hidden = false;
}

,initRenderData:function() {
var me = this;
return me.callParent(arguments);
}
});



The new RowAction works but there is only one problem, the initRenderData function is called before onLoad function. How could i solve this problem?

Thanks.

mitchellsimoens
29 Dec 2011, 11:43 AM
You may have to edit the RowActions ux to get what you want

foxmarco
30 Dec 2011, 2:19 PM
how?