Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get value of other column in renderer function in Extjs?

I want to get the value of another column in the same row, in a renderer function of one column. I tried a method, but it didn't work. And here's my code:

columns: [
            {id:'id',header: 'ID', width: 30, sortable: true, dataIndex: 'category_id'},

            {header: 'current_level', width: 100, sortable: true, dataIndex: 'current_level'},
            {header: 'complete_code', width: 100, sortable: true, dataIndex: 'complete_code'},
            {header: 'parent_id', width: 100, sortable: true, dataIndex: 'parent_id'},
            {header: 'parent_name', width: 100, sortable: true, dataIndex: 'parent_name'},
            {
                header: 'has_standards', width: 100, sortable: true, dataIndex: 'has_standards',
                renderer: function(val, meta, record, rowIndex) {
                    if (val == 'Yes') {
                        console.log(record.data.category_id);
                    }
                }
            }
        ],

As you see, I want to get the category_id in the same row, in the renderer function of has_standards column. But my way is wrong. Could you tell me how to do it?

like image 480
Mingrui Ji Avatar asked Nov 11 '13 13:11

Mingrui Ji


1 Answers

You want to use record.get('category_id') e.g.:

           renderer: function(val, meta, record, rowIndex) {
                if (val === 'Yes') {
                    console.log(record.get('category_id'));
                }else{
                    console.log('Value is not "Yes"');
                }
            }
like image 98
SW4 Avatar answered Nov 11 '22 06:11

SW4