Results 1 to 6 of 6

Thread: Cell clicked

  1. #1
    Sencha User crysfel's Avatar
    Join Date
    Feb 2008
    Location
    New York, USA
    Posts
    218

    Default Cell clicked

    Hi folks.

    Is there a way to know which cell is clicked by the user? at the moment I have this:

    PHP Code:
    me.control({
        
    "gridpanel"    : {
            
    itemclick    me.myCallback
        
    }
    }); 
    The callback function only receive six params:

    PHP Code:
    myCallback : function( gridrecordhtmlItemrowIndexeventoptions){


    There's the rowIndex but not a cellIndex, is there a way to know the cell index?? actually I want to know the field of the record that have been clicked in the grid.

    Best regards

  2. #2
    Sencha User crysfel's Avatar
    Join Date
    Feb 2008
    Location
    New York, USA
    Posts
    218

    Default

    Ok, I did it, but I'm not sure it there's a better way, this is what I did:

    PHP Code:
    myCallback : function( gridrecordhtmlItemrowIndexeventoptions){
        var 
    clicked grid.getSelectionModel().getCurrentPosition(),
             
    dataIndex grid.panel.columns[clicked.column].dataIndex;

        
    console.log(dataIndex);

    This way I get the dataIndex that was clicked in the grid, but as I said, I'm not sure if there's a better way to do this, if so please let me know.

    Best regards

  3. #3
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522

    Default

    I'm not sure if this works in your situation, but you can use "cellclick" instead of "itemclick". In that case, your callback would receive these params, including the column index:

    Code:
    myCallback: function(grid,column,columnIndex,record,row,rowIndex,...) {
      ....
    }
    

  4. #4
    Sencha Premium User d.zucconi's Avatar
    Join Date
    Jun 2008
    Location
    Piacenza (Italy)
    Posts
    102

    Default

    Quote Originally Posted by existdissolve View Post
    ... but you can use "cellclick" instead of "itemclick". In that case, your callback would receive these params, including the column index...
    Where do I can get some documentation about this event ? I've looked directly into source code (through API docs) but I didn't find any information about "cellclick" event on Ext4 grids or views.

  5. #5
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522

    Default

    Hi @d.zucconi--

    Take a look at http://docs.sencha.com/ext-js/4-0/source/Table3.html

    You'll find it in this section:

    Code:
    processItemEvent: function(record, row, rowIndex, e) {
            var me = this,
                cell = e.getTarget(me.cellSelector, row),
                cellIndex = cell ? cell.cellIndex : -1,
                map = me.statics().EventMap,
                selModel = me.getSelectionModel(),
                type = e.type,
                result;
    
    
            if (type == 'keydown' && !cell && selModel.getCurrentPosition) {
                // CellModel, otherwise we can't tell which cell to invoke
                cell = me.getCellByPosition(selModel.getCurrentPosition());
                if (cell) {
                    cell = cell.dom;
                    cellIndex = cell.cellIndex;
                }
            }
    
    
            result = me.fireEvent('uievent', type, me, cell, rowIndex, cellIndex, e);
    
    
            if (result === false || me.callParent(arguments) === false) {
                return false;
            }
    
    
            // Don't handle cellmouseenter and cellmouseleave events for now
            if (type == 'mouseover' || type == 'mouseout') {
                return true;
            }
    
    
            return !(
                // We are adding cell and feature events
                (me['onBeforeCell' + map[type]](cell, cellIndex, record, row, rowIndex, e) === false) ||
                (me.fireEvent('beforecell' + type, me, cell, cellIndex, record, row, rowIndex, e) === false) ||
                (me['onCell' + map[type]](cell, cellIndex, record, row, rowIndex, e) === false) ||
                (me.fireEvent('cell' + type, me, cell, cellIndex, record, row, rowIndex, e) === false)
            );
        },

  6. #6
    Sencha Premium User d.zucconi's Avatar
    Join Date
    Jun 2008
    Location
    Piacenza (Italy)
    Posts
    102

    Thumbs up

    Quote Originally Posted by existdissolve View Post
    Hi @d.zucconi--

    Take a look at http://docs.sencha.com/ext-js/4-0/source/Table3.html

    [/CODE]
    Thanks existdissolve

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •