Search code examples
javascriptextjsextjs4

How to get other column value on selecting a checkbox on a tree grid


I have a tree grid and there are two columns Duration and a checkbox column. What i want is when i select / deselect checkbox I should get Duration column value. This is the code i have tried But dont know as how do I access the Duration value.

{
    xtype: 'nacheckcolumn', //only display checkbox on leaf items(tasks)
    header: 'N/A',
    dataIndex: 'NA',
    menuDisabled: true,
    width: 60,
    sortable: false,
    editor: {
        xtype: 'checkbox',
        cls: 'x-grid-checkheader-editor'
    },
    listeners: {
        'checkchange': function (column, recordIndex, checked) {
            console.log(checked);                              
            if(checked === true) {
            }
        }
    }                                
}

Solution

  • Get the record from the recordIndex :

    var record = column.up('grid').getStore().getAt(recordIndex) 
    

    Then get the value of the desired column :

    var duration = record.get('duration') 
    

    Together :

    'checkchange': function (column, recordIndex, checked) { 
        console.log(checked);
        if(checked === true) {
            var record = column.up('grid').getStore().getAt(recordIndex), 
            duration = record.get('duration') 
        }
    }