We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1778
    • 659 Posts
    Hi all,
    Not sure if it’s the right place to post this question, but ...

    I’m developping a 3PC for Revo, and I’m using a combobox in a window. The combobox works fine and does its job, no problem.
    The only thing is : I would like to have in the "displayField’ the values of two colums instead of the value of only one... Is it possible and if yes how is it ?

    I actually have something like :
    myComp.combo.Company = function(config){
    	config = config || {};
    	
    	Ext.applyIf(config,{
    		hiddenName: 'id',
    		displayField: 'name',
    		valueField: 'id',
    		fields: ['id','name','office'],
    		url: myComp.config.connector_url,
    		baseParams:{
    			action: 'mgr/company/getlist'
    		}
    	});
    
    	myComp.combo.Company.superclass.constructor.call(this,config);
    };
    Ext.extend(myComp.combo.Company,MODx.combo.ComboBox);
    Ext.reg('mycomp-combo-company',myComp.combo.Company);
    


    And I’d like to display in the drop-down list something like : "name (office)"... I can’t find any clue on how to achieve this if it is doable..
    Thanks
    Cheers
      • 28215
      • 4,149 Posts
      Yep, using the ’tpl’ property and XTemplate:

      ,tpl: new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">{name} ({office})</div></tpl>')
      


      And of course you can add span tags to that to give it some styling, and such.
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 1778
        • 659 Posts
        Hi Shaun,

        Thanks for this fast answer, I’ll try it immediatly...
        Thanks again
          • 1778
          • 659 Posts
          Hello,

          I make my way step by step... My window works fine now, another question now
          I have a grid with this code (simplified)

          Cispeo.grid.Projects = function(config){
          	config = config || {};
          	
          	Ext.applyIf(config,{
          		id: 'cispeo-grid-projects',
          		url: Cispeo.config.connector_url,
          		baseParams: {
          			action: 'mgr/project/getlist',
          			company: config.company
          		},
          		fields:['id','owner','name','start_date_plan','start_date_real','end_date_plan','end_date_real','status','deleted'],
          	autoHeight: true,
                  paging: true,
                  remoteSort: true,
          		autosave: false,
          		primaryKey: ('id'),
          		stripeRows: true,
          		columns: [{
          			header: _('id'),
          			dataIndex: 'id',
          			width: 20
          		},{
          			header: _('cispeo.project_owner'), // this column is filled in by the combobox
                                  dataIndex: 'owner',
          			width: 40
          		},{
          			header: 'owner_name', // in this colum I'd like to display 'company.name (company.office)'
          			dataIndex: 'owner',
          			width: 200,
          			renderer: this.renderCompany // don't know how !!!
          		},{
          			header: _('name'),
          			dataIndex: 'name',
          			width: 150
          		}
                          [... etc...]
          


          In my previous post, I fill the column ’owner’ via a combo-box in a window, the column is filled with the (Company) owner’s ID.
          I’d would like in the column ’owner_name’ to display the name and the office name for the Company. If I understand correctly I have to specify a renderer (renderCompany) but I can’t figure how to load and display the correct data (the right name and office). I don’t feel very comfortable with ExtJS...

          I suppose I have to ’load’ a hidden store with the companies data (may be the grid ’companies’ that is displayed in an other tab? ) and have to lookup through it to find the infos for the ID provided by ’owner’ column ... But how?

          Of course I have 2 classes in my schema, (Company and Project where Project.owner = Company.id)...

          I need some guidance on this...
          Thanks