1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    14
    Vote Rating
    0
    sukant.sahoo is on a distinguished road

      0  

    Default combobox as editor in grid not loading for 2nd time

    combobox as editor in grid not loading for 2nd time


    Hi

    I have grid having combobox as editor in one column.
    To update a record in grid , I want to select data from combobox editor.
    First time the data in combo box loading.
    It means
    After data loaded in the grid after page loaded(grid object newly created ) then if I click on the combo box editor it is loading data proper.
    If I reload the grid after selecting value for combobox editor then I click the combobox editor , it is not loading the data.

    To reload the grid I used reconfigure API.

    I have attached screen shot for reference. Please help ASAP.
    Attached Images

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,935
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Please check the following. I was not able to duplicate what you described.

    Code:
    Ext.onReady(function(){
        // sample static data for the store
        var myData = [
            ['3m Co',                               71.72, 0.02,  0.03,  '9/1 12:00am'],
            ['Alcoa Inc',                           29.01, 0.42,  1.47,  '9/1 12:00am'],
            ['Altria Group Inc',                    83.81, 0.28,  0.34,  '9/1 12:00am'],
            ['American Express Company',            52.55, 0.01,  0.02,  '9/1 12:00am'],
            ['American International Group, Inc.',  64.13, 0.31,  0.49,  '9/1 12:00am'],
            ['Verizon Communications',              35.57, 0.39,  1.11,  '9/1 12:00am'],            
            ['Wal-Mart Stores, Inc.',               45.45, 0.73,  1.63,  '9/1 12:00am']
        ];
    
        // create the data store
        var store = new Ext.data.ArrayStore({
            fields: [
               {name: 'company'},
               {name: 'price',      type: 'float'},
               {name: 'change',     type: 'float'},
               {name: 'pctChange',  type: 'float'},
               {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
            ]
        });
    
        // manually load local data
        store.loadData(myData);
    
        var combo = new Ext.form.ComboBox({
            typeAhead: true,
            triggerAction: 'all',
            lazyRender:true,
            mode: 'local',
            store: new Ext.data.ArrayStore({
                id: 0,
                fields: [
                    'displayText'
                ],
                data: [['Company One'], ['Company Two']]
            }),
            valueField: 'displayText',
            displayField: 'displayText'
        });
    
        // create the Grid
        var grid = new Ext.grid.EditorGridPanel({
            store: store,
            columns: [
                {
                    id       :'company',
                    header   : 'Company', 
                    width    : 160, 
                    sortable : true, 
                    dataIndex: 'company',
                    editor: combo
                },
                {
                    header   : 'Price', 
                    width    : 75, 
                    sortable : true, 
                    renderer : 'usMoney', 
                    dataIndex: 'price',
                    editor: {
                        xtype: 'textfield',
                        allowBlank: false
                    }
                },
                {
                    header   : 'Change', 
                    width    : 75, 
                    sortable : true, 
                    dataIndex: 'change',
                    editor: {
                        xtype: 'textfield',
                        allowBlank: false
                    }
                },
                {
                    header   : '% Change', 
                    width    : 75, 
                    sortable : true, 
                    dataIndex: 'pctChange'
                },
                {
                    header   : 'Last Updated', 
                    width    : 85, 
                    sortable : true, 
                    renderer : Ext.util.Format.dateRenderer('m/d/Y'), 
                    dataIndex: 'lastChange'
                }
            ],
    
            tbar: [{
                text: 'Reload Store',
                handler: function(){
                    store.load();
                }
            }],
    
            stripeRows: true,
            autoExpandColumn: 'company',
            height: 350,
            width: 600,
            title: 'Array Grid',
            renderTo: Ext.getBody()
        });
    
    });
    Scott

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    14
    Vote Rating
    0
    sukant.sahoo is on a distinguished road

      0  

    Default


    hi Scott,

    Thanks for ur quick reply.
    I am not seeing the code to refresh the gird data.
    Could please provide the refresh the grid data?
    After first time loading of grid, click on combobox editor then refresh the grid data then click on combobox editor again.

  4. #4
    Sencha User
    Join Date
    Jun 2011
    Posts
    14
    Vote Rating
    0
    sukant.sahoo is on a distinguished road

      0  

    Default


    This code will refresh the grid u load the js file in browser.
    And every time it will create new object of grid. then this problem will not occur.
    Instead of creating new grid object every time use reconfigure api of ext-js to reload the grid second time.
    Please let me know if u r not getting me.

  5. #5
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,935
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    To make sure I understand .. I load the store and combo. I then click on the button in the toolbar and it loads the grid data again. At this time when I edit the grid, the combo still has it's data.

    Is this correct?

    Scott.

  6. #6
    Sencha User
    Join Date
    Jun 2011
    Posts
    14
    Vote Rating
    0
    sukant.sahoo is on a distinguished road

      0  

    Default


    before loading(refresh) the second time edit it. and then click on combobox editor.<br>If possible while loading grid second time reconfigure the column model because in my code I am reconfigure column model.<br>I am suspecting because of reconfigure it is not working.<br>

  7. #7
    Sencha User
    Join Date
    Jun 2011
    Posts
    14
    Vote Rating
    0
    sukant.sahoo is on a distinguished road

      0  

    Default


    Hi Scott,

    Use the following code to reconfigure the grid.
    var refGrid = Ext.getCmp('refKeyGrid');
    refGrid.reconfigure(refGrid.getStore(), new Ext.grid.ColumnModel(myCM));

    In my scenario, runtime I am updating column heading. So instead creating grid again I am reconfiguring the grid with update column model. I am using the above code to reconfiguring grid.

    Please try my scenario and it is reproducible. If there is other way to update column heading at run time please let me know.

    Thanks
    Sukant

  8. #8
    Sencha User
    Join Date
    Jun 2011
    Posts
    14
    Vote Rating
    0
    sukant.sahoo is on a distinguished road

      0  

    Default


    combo box editor firing ajax request and in store data is available but not showing in the dropdown.
    please help me

  9. #9
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,935
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Do you think you have a timing issue? Since you making an ajax call? I am left guessing as I am not sure what you are doing. Can you modify the example? You can use a static JSON file to simulate the return data.

    Scott.

  10. #10
    Sencha User
    Join Date
    Jun 2011
    Posts
    14
    Vote Rating
    0
    sukant.sahoo is on a distinguished road

      0  

    Default


    Hi Scott,

    There is no timing issue. I tried with static data and 'mode:local' in combo box editor.Still it is same issue.
    When page load freshly at that time the combo box editor is working fine. After reconfigure grid it is not working. I think there is no issue in reconfiguring grid. Because I tried the same approach in different screen it is working. Only difference is, here I am forming column model in java(dynamically).
    Is there any difference in 'xtype:combo' and 'new Ext.form.ComboBox'
    I am attaching two screen shot. 2nd screen shot is after reconfiguring grid.
    If you need particular code please let me know.

    sukant
    Attached Images

Thread Participants: 1