Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: How to call editor on any cell in grid?

  1. #1
    Sencha User biohazardo's Avatar
    Join Date
    Jan 2012
    Posts
    48
    Vote Rating
    -1
      0  

    Question Answered: How to call editor on any cell in grid?

    Hello. I have RecordIndex, and I know column name. How can I call editor on the cell with focused cursor? Thanks.

  2. 1. What do you mean with 'columnName'?
    2. With Ext.grid.plugin.CellEditing you have some ways to start edit a cell:
    • If you know the position of the cell (rowIndex, columnIndex) you can use <editor>.startEditByPosition({row: rowIndex, column: columnIndex}).
    • If you know the record and columnHeader object that defines the column (not column name), you can use <editor>.startEdit(record, columnHeader)

  3. #2
    Sencha - Community Support Team mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,023
    Answers
    3976
    Vote Rating
    1334
      0  
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  4. #3
    Sencha User biohazardo's Avatar
    Join Date
    Jan 2012
    Posts
    48
    Vote Rating
    -1
      0  

    Default

    But how can I start edit from listener of editor. I have listener on "Enter" key:
    Code:
                listeners:{                specialkey: function(field, e){
    
    
                        if (e.getKey() == e.ENTER) {
                            var grid = Ext.getCmp('sheetproductionrestin');
                            var store = Ext.getCmp('sheetproductionrestin').store;
                            var selModel = grid.getSelectionModel();
                            var selectedRecord = selModel.getLastSelected();
    
    
                            var recordIndex = store.indexOf(selectedRecord);
                            var nextRecord = store.getAt(recordIndex + 1);
                            selModel.select(nextRecord);
                            var cellEditing = Ext.create('Ext.grid.plugin.CellEditing');
    
    
                            
                            cellEditing.startEdit(nextRecord,field.name)
    
    
                        }
                    }
                }
    This cellEditing drops error "Uncaught TypeError: Cannot read property 'store' of undefined".
    Maybe I need to do it by another path?

    And how can I access grid not by ID, but relatively.

  5. #4
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    117
      0  

    Default

    You should post the code of defining your grid for reference then someone can help to find the solution.

  6. #5
    Sencha User biohazardo's Avatar
    Join Date
    Jan 2012
    Posts
    48
    Vote Rating
    -1
      0  

    Default

    I could select Editing from grid by grid.plugins[0];

    Now I can't give parameters in StartEdit. I don't know how to take column or row from grid, to give if to Editing.startEdit(nextRecord,field);

    In console i have: Uncaught TypeError: Object [object Object] has no method 'getIndex'
    I don't understand, what is Ext.data.Model and how to take it. I know recordIndex and columnName. How I can call StartEdit correct?

  7. #6
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    117
      0  

    Default

    1. What do you mean with 'columnName'?
    2. With Ext.grid.plugin.CellEditing you have some ways to start edit a cell:
    • If you know the position of the cell (rowIndex, columnIndex) you can use <editor>.startEditByPosition({row: rowIndex, column: columnIndex}).
    • If you know the record and columnHeader object that defines the column (not column name), you can use <editor>.startEdit(record, columnHeader)

  8. #7
    Sencha User biohazardo's Avatar
    Join Date
    Jan 2012
    Posts
    48
    Vote Rating
    -1
      0  

    Default

    This code helped to get Column Model and open editor at cell: var column = grid.getView().getHeaderCt().getHeaderAtIndex(5);
    But how can I select column index here (I entered 5 here for test). I have only field, that gives listener event: specialkey: function(field, e){..}

    But I want to take index from given field, because I have several different editors. How to take index? How to take that "columnHeader"?

  9. #8
    Sencha User biohazardo's Avatar
    Join Date
    Jan 2012
    Posts
    48
    Vote Rating
    -1
      0  

    Default

    Quote Originally Posted by vietits View Post
    1. What do you mean with 'columnName'?
    When the listener gives me field, I can take it's name in table by field.name.

  10. #9
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    117
      0  

    Default

    You can get information from the current editing context of the editor plugin:
    Code:
    listeners: {
        specialKey: function(){
            var editor = grid.getPlugin('Your plugin id here'); // or grid.plugins[0] if you know the index of editor plugin
            var context = editor.context;
            console.log(context);
            .....
        }
    }

  11. #10
    Sencha User biohazardo's Avatar
    Join Date
    Jan 2012
    Posts
    48
    Vote Rating
    -1
      0  

    Default

    Quote Originally Posted by vietits View Post
    You can get information from the current editing context of the editor plugin:
    Code:
    listeners: {
        specialKey: function(){
            var editor = grid.getPlugin('Your plugin id here'); // or grid.plugins[0] if you know the index of editor plugin
            var context = editor.context;
            console.log(context);
            .....
        }
    }
    Thanks. It works. Now it can create new Editor in same field, but new Editor hides in short. I see it for milliseconds. But sometimes it doesn't hide. It seems like bug, but I don't know. Where I need to look for that?

    And how I can to take parent grid of Editor without ID. Relativity. How to access it?

Page 1 of 2 12 LastLast

Posting Permissions

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