I
I
Ilya Ponomarev2015-06-24 20:44:48
MODX
Ilya Ponomarev, 2015-06-24 20:44:48

How to display data from the database in MODx.combo.ComboBox?

Good day!
I started to understand the creation of components for Modx Revo and a problem arose:
There is a table in which we store reviews for the catalog of companies in it fields like: id, text, name, company_id. In the admin panel of the component, we can create and edit reviews, but (!) It is very inconvenient to follow them by the company ID, so it would be great to take the name of this company from the database and replace the number with it, but keep the number at the same time.
Combobox example. How can I change it to suit my needs. I know that you can connect a connector (URL field), but in what form should it give out data?, unless of course I understood the essence of the connector correctly

EWreview.combo.Rate = function(config) {
    config = config || {};
    Ext.applyIf(config,{
        store: new Ext.data.ArrayStore({
            id: 0
            ,fields: ['rate','display']
            ,url: ??????????????
            ,data: [
                ['1','1']
                ,['2','2']
                ,['3','3']
                ,['4','4']
                ,['5','5']
            ]
        })
        ,mode: 'local'
        ,displayField: 'display'
        ,valueField: 'rate'
    });
    EWreview.combo.Rate.superclass.constructor.call(this,config);
};
Ext.extend(EWreview.combo.Rate,MODx.combo.ComboBox);
Ext.reg('ewreview-combo-rate',EWreview.combo.Rate);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Ponomarev, 2015-06-24
@Eli_Jah

I asked myself, I answered

EWreview.combo.Rate = function(config) {
    config = config || {};
    Ext.applyIf(config,{
        name: 'name'
        ,hiddenName: 'product_id'
        ,displayField: 'name'
        ,valueField: 'product_id'
        ,fields: ['product_id','name']
        ,pageSize: 20
        ,url: EWreview.config.connector_url
        ,baseParams: {
            action: 'ew/getlist'
        }
        ,typeAhead: true
        ,editable: true
    });
    EWreview.combo.Rate.superclass.constructor.call(this,config);
};
Ext.extend(EWreview.combo.Rate,MODx.combo.ComboBox);
Ext.reg('ewreview-combo-rate',EWreview.combo.Rate);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question