Hello
@TheWebScientist : thanks for your infos, but that was not my problem... I know how to render properly something in a grid,
or in a combo-box.
My problem was to "prefill" a field in window accessed via a context menu on an item in a grid and...
@skndn60 : I FOUND IT !
Based on my first post I have this URL
From this grid, via a context menu I call the handler ’manageCompany’ with this code
manageCompany: function(btn,e){
location.href = '?a='+MODx.request.a+'&action=company&id='+this.menu.record.id;
}
This code send me to another panel ’Cispeo.company.panel’. The URL displayed in my browser is then :
"localhost/Master/manager/?a=76&action=company&id=1" (where ’&id=1’ is the company’s ID.) This works fine.
What I wanted was to "prefill the owner field with the company’s ID (or at least hide the field but set its value with the company ID)."
So I have not (yet) find a way to display it, but I set and save the good company’s ID (the good owner), so I can create a project from the ’CompanyProjects’ grid (with the projects for this particular company), and no need to choose the owner again... Exactly what I wanted...
How I did it ? First I extracted the company ID from the URL, then I ’assign’ it as baseParam in my window... I don’t show it, but its value is sent to the processor (create.php), and treated in the $_POST as the other fields...
I suppose we can do the same or equivalent with datas extracted from other tables if needed...
To illustrate I post my window code. The create.php is based on the one provided in modExtra...
Cispeo.window.createCompanyProject = function(config){
config = config || {};
<!-- extraction of id -->
var t = location.search.substring(1).split('&');
var f = [];
for (var i=0; i<t.length; i++) {
var x = t[i].split('=');
f[x[0]]=f[1];
}
var myOwner = x[1];
this.owner = myOwner;
this.ident = config.ident || 'cpocproject'+Ext.id();
Ext.applyIf(config,{
title: _('cispeo.project_create'),
id: this.ident,
owner: this.owner,
width: 600,
url: Cispeo.config.connector_url,
// send owner as param for creation
baseParams: {
owner:this.owner,
action: 'mgr/project/create'
},
fields: [{
name: 'owner',
fieldLabel: myOwner // this one was just to be sure...
},{
xtype: 'textfield',
name: 'name',
fieldLabel: _('name')
}]
});
Cispeo.window.createCompanyProject.superclass.constructor.call(this,config);
};
Ext.extend(Cispeo.window.createCompanyProject,MODx.Window);
Ext.reg('cispeo-window-companyproject-create',Cispeo.window.createCompanyProject);
Hope this is of use...
Cheers