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 User skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,338
    Vote Rating
    248
    skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of skirtle has much to be proud of

      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,332
    Vote Rating
    83
    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

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar