Results 1 to 3 of 3

Thread: RowEditing with Combobox - changes shown "id", should be displayed "displayField"

  1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    1

    Default RowEditing with Combobox - changes shown "id", should be displayed "displayField"

    Hi)
    RowEditing with Combobox - changes (click row editing) shown "id"
    should be displayed "displayField"


    extjs_cb.gif

    Code:
    Ext.define('ModelLib', {            
    extend: 'Ext.data.Model',
                fields: [
                    'trID',
                    'trName'
                ]
            });
            var storeServer = Ext.create('Ext.data.Store', {
                autoDestroy: true,
                model: 'ModelLib',
                proxy: {
                    type: 'ajax',
                    api: {
                        read: '/api.php?lib=server&act=get'
                    },
                    reader: {
                        type: 'json',
                        root: 'fields',
                        idProperty: "trID"
                    }
                },
                sorters: [{
                    property: 'trID',
                    direction: 'ASC'
                }]
            });
            storeServer.load();
    
    
            Ext.define('ModelMainobjects', {
                extend: 'Ext.data.Model',
                fields: [
                    {name: 'trServerID',   type: 'int'}
                ]
            });
    
    
            var store = Ext.create('Ext.data.Store', {
                // destroy the store if the grid is destroyed
                autoDestroy: true,
                autoSync : true,
                model: 'ModelMainobjects',
                proxy: {
                    type: 'ajax',
                    api: {
                        read: '/api.php?lib=mainobjects&act=get',
                        update: '/api.php?lib=mainobjects&act=update'
                    },
                    reader: {
                        type: 'json',
                        root: 'fields',
                        idProperty: "trID"
                    },
                    writer: {
                        type: 'json'
                    }
                },
                sorters: [{
                    property: 'trID',
                    direction: 'ASC'
                }]
            });
    
    
            store.load();
    
    
            var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
                clicksToMoveEditor: 1,
                autoCancel: false
            });
    
    
            var rowRenderer = function(val) {
                var rec = storeServer.findRecord('id', val);
                return rec !== null ? rec.get("trName") : ''
            };
    
    
            
            var grid = Ext.create('Ext.grid.Panel', {
                store: store,
                columns: [
                {
                    header: '??????',
                    dataIndex: 'trServerID',
                    renderer: rowRenderer,
                    editor: {
                        xtype: 'combobox',
                        store: storeServer,
                        queryMode: 'local',
                        displayField: 'trName',
                        valueField: 'trID'
                    }
                }],
                width: 600,
                height: 400,
                plugins: [rowEditing]
            });

  2. #2
    Sencha Premium Member
    Join Date
    Oct 2012
    Posts
    18
    Answers
    1

    Default

    I had this problem as well.
    I ended up setting the column.dataIndex, comobobox.dispalyField and combobox.valueField to the field that should be shown - in my case 'name'.
    Then I used the Select event of the combobox to update the field. Select provides the full record in its arguments, so you can still get the ID from it.

    Also, you'll probably have better luck if you post this in the discussion thread of the specific EXTJS version you are using.

  3. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    1

    Default

    I found the solution
    Code:
    Ext.define('ModelLib', { 
    extend: 'Ext.data.Model', 
    fields: [ 
    {name: 'trID', type: 'int'}, 
    {name: 'trName', type: 'string'} 
    ] 
    });
    need to specify the type of field

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •