1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    40
    Vote Rating
    0
    teddy11 is on a distinguished road

      0  

    Default grid: cell value variable

    grid: cell value variable


    Hello,

    I have a grid with two columns. The data is in an array "Column A" and "Column B".
    The first column value is known and added to the array but the column b is a calculated field. I have looked all over and I can't figure out how to do this. Is it possible to do this and if so, Does anyone have an example?

  2. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,585
    Vote Rating
    319
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    Which ExtJS version is this? Please post questions in the relevant help forum.

    You'd do this using a renderer function on the column. The renderer is passed the whole record for the row so you can do whatever calculations are required.

  3. #3
    Sencha - Community Support Team sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,333
    Vote Rating
    85
    sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough sword-it is a jewel in the rough

      0  

    Default


    Hello
    Try to use following code for fill the value in second column after calculation
    Code:
        var arrayStore= function () {
            return [
                [ '500'],
                [ '1234'],
                [ '3000'],
    
            ];
        }
        var selModel= function () {
            return new Ext.grid.RowSelectionModel({
                singleSelect: true
            });
        }
        var calculatedValue = function (values, metadata, record) {
            return (record.get('price') * 5);
        }
        var colModel= function () {
            return new Ext.grid.ColumnModel([
                    {
                        header: 'Column A'
                        , dataIndex: 'price'
                    },
                    {
                        header: 'Column B'
                        , renderer: calculatedValue
                    }
            ]);
        }
        
        var win = new Ext.Window({
            title: 'My Window'
            , width: 400
            , height: 400
            , layout: 'form'
            , items: [
                {
                    xtype: 'grid'
                    , width: 380
                    , height: 200
                    , viewConfig: {
                        forceFit: true
                    }
                    , title: 'My First Grid'
                    , store: new Ext.data.ArrayStore({
                        data: arrayStore()
                        , fields: ['price']
                    })
                    , colModel: colModel()
                    , selModel: selModel()
                }
            ]
        });
        Ext.onReady(function () {
            win.show();
        })
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi