1. #51
    Sencha User
    Join Date
    Sep 2009
    Posts
    53
    Vote Rating
    0
    vmadman is on a distinguished road

      0  

    Default


    Nevermind, it ports just fine. My troubles were elsewhere, in my own code.

  2. #52
    Ext User
    Join Date
    Aug 2010
    Posts
    1
    Vote Rating
    0
    gozargozarian is on a distinguished road

      0  

    Default Reloading Field Editors?

    Reloading Field Editors?


    If I try to use the code to add a new SelectionModel type of column, such as CheckBoxSelectionModel. Then it loses the field editors that were attached to each field in the Grid. Is there a way to trigger reloading of the field editors on an editable grid?

    Thanks!

  3. #53
    Ext JS Premium Member
    Join Date
    Feb 2009
    Posts
    449
    Vote Rating
    5
    Jangla is on a distinguished road

      0  

    Default


    I/m trying to use the code to add a rowActions column (as per the Ext.ux.grid.RowActions control) but it doesn't want to play. Any tips appreciated.

    Edit - actually got that cracked although it seems that adding an id to the addColumn call doesn't affect where the column is added for me; it's always the last column to the right

  4. #54
    Sencha User
    Join Date
    Dec 2010
    Posts
    9
    Vote Rating
    0
    colinm is on a distinguished road

      0  

    Default


    Hi condor ... very nice post .. but what about duplicating a column ... ?? (or adding a column with specific data ... other than default value?).

    i tried to add a duplicateSelectedColumn in between the remove and the add column of your code, but i am facing several problems. before to continue, do you have an easy way to do this?

    thanks!

  5. #55
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    97
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    You could add a copy of an existing column config, but that won't work for the editor (you'll have to clone() it).

  6. #56
    Sencha User
    Join Date
    Dec 2010
    Posts
    9
    Vote Rating
    0
    colinm is on a distinguished road

      0  

    Default Duplicating columns

    Duplicating columns


    thanks for the answer ... so i should clone the config of the interested column....
    i did something maybe similar. Inside your remove and add columns methods of the gridpanel (btw: i changed it to an editorGridPanel), i did the following

    Code:
    duplicateSelectedColumn: function(){
            if (this.selModel.selection) 
            {
                duplicatenum +=1;
                var columnindex=this.selModel.selection.cell[1];
                var curcolumn=this.colModel.columns[columnindex];
                var newheader=curcolumn.header+duplicatenum;
    	return this.colModel.addColumn({header:newheader, dataindex:newheader,  editor: new Ext.form.TextField({ allowBlank: false})}, columnindex);
            }
            else{ Ext.Msg.alert('select a column first');}
    },
    this works fine and add a new column with a new header ... strangely, all fields appear with the same values as the column which was at that column index ... the problem is that these values are not really duplicated (eg. i can't change their value .. but if i change the values of the row which was at that location, the values of the duplicated column change in the same time)
    do you have any hints about how to duplicate them?

    thanx a lot

  7. #57
    Sencha User
    Join Date
    Nov 2010
    Posts
    37
    Vote Rating
    0
    alok000707 is on a distinguished road

      0  

    Default how to add fields dyanmically while adding columns dynamicallyl

    how to add fields dyanmically while adding columns dynamicallyl


    Hi COndor,

    Thanks for the code.

    I had successfully added the column into the grid panel.

    But I am not able to add field dyanmically.

    I tried the code given by you, but the data is not reflecting in the grid.

    Please suggest, what I need to do to proceed.

    THe following is the code snippet that I am implementing.

    Code:
        var dataIndex = 'conversionRateKey.'+currencyCode;
        grid5.addColumn({name:dataIndex},{header: currencyCode, dataIndex: dataIndex},3);
    this code is able to add column successfully but not able to fetch data from json.

    Please help.

    Regards
    Alok

  8. #58
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    97
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    What exactly do you mean by "not able to fetch data from json"?

  9. #59
    Sencha User
    Join Date
    Nov 2010
    Posts
    37
    Vote Rating
    0
    alok000707 is on a distinguished road

      0  

    Default


    let me explain you the situation..

    I have data as follows:

    Code:
    var myData = [
            ['3m Co',                     71.72, 0.02,  0.03,  'for new col'],
            ['Alcoa Inc',                 29.01, 0.42,  1.47,  'for new col'],
            ['Altria Group Inc',          83.81, 0.28,  0.34,  'for new col'],
            ['American Express Company',  52.55, 0.01,  0.02,  'for new col']       
        ];
    Following is my store and fields, where I defined only 4 fields. so that I can add the last field dynamically.

    Code:
     var store = new Ext.data.ArrayStore({
            fields: [
               {name: 'company'},
               {name: 'price',      type: 'float'},
               {name: 'change',     type: 'float'},
               {name: 'pctChange',  type: 'float'}           
            ]
        });
    
     // manually load local data
        store.loadData(myData);
    and this is my grid where I am adding new column,

    Code:
        // create the Grid
        var grid = new Ext.grid.GridPanel({
            store: store,
            columns: [
                {
                    id       :'company',
                    header   : 'Company', 
                    width    : 160, 
                    sortable : true, 
                    dataIndex: 'company'
                },
                {
                    header   : 'Price', 
                    width    : 75, 
                    sortable : true,                 
                    dataIndex: 'price'
                },
                {
                    header   : 'Change', 
                    width    : 75, 
                    sortable : true, 
                    renderer : change, 
                    dataIndex: 'change'
                },
                {
                    header   : '% Change', 
                    width    : 75, 
                    sortable : true,                 
                    dataIndex: 'pctChange'
                }
            ],
            stripeRows: true,
            autoExpandColumn: 'company',
            height: 350,
            width: 600,
            title: 'Array Grid',    
          
        });
    
        // render the grid to the specified div in the page
        grid.render('grid-example');
       //adding new column 
    grid.addColumn({name: 'D', defaultValue:'D'}, {header: 'D', dataIndex: 'D'});
    Now I want that, on adding to column D the extra data coming in store get showed in it. Column is successfully adding into the grid but data is not get populated.

  10. #60
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    97
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    No, it won't automatically populate. For that you would need to reload the store.