Results 1 to 4 of 4

Thread: Can I get rowId or record from field or event parameter when using listener speciakey

  1. #1
    Sencha User
    Join Date
    Sep 2018
    Location
    Earth
    Posts
    2

    Default Can I get rowId or record from field or event parameter when using listener speciakey

    Sorry if this is a duplicate thread, but i couldn't find anything matching my problem...
    I'll try putting this as easily understandable as possible.

    In my view i have the following (stating only the important stuff):
    MyView:
    extend: 'Ext.tree.Panel',
    columns:
    {
    items: [
    {
    editor:
    {
    xtype: 'textfield',
    enableKeyEvents: true,
    listeners:
    {
    specialkey: 'doStuffInController'
    }
    }
    } ]
    }

    MyViewController (again only important things):
    extend: 'Ext.app.ViewController',
    doStuffInController: function(field, event)
    {
    var me = this,
    selectedRecord = me.getView().getStore().getModifiedRecords()[0];
    }

    What I want to achieve:Instead of the selectedRecord at position 0, I want the record connected to the field that I'm just editing.

    So now my question:
    Is there a way to get the exact record of which I'm just editing the textfield? Either through parameter 'field', or 'event', or is there a way to pass it with an extra argument, and if so, how is the syntax for that?

    So far I have only found a very ugly way that I can't and don't want to use, even though it works with Ext JS 6.0.2
    selectedRecord = field.ownerCt.grid.plugins[0].context.record;


    Thanks already, any help is appreciated!

  2. #2
    Sencha MVP Team Member
    Join Date
    Sep 2016
    Location
    Kennewick, WA
    Posts
    150
    Answers
    15

    Default

    The only things passed are as follows

    Code:
    listeners: {
        specialkey: function (this, field, event, eOpts) {
           // Do stuff here
        }
    }
    You can go from the field, working up to the grid, the store, the selection model, and then the selection.

    Code:
    field.up('grid').getView().getSelectionModel().getSelection();
    Andy Allord
    Sencha MVP/Software Engineer

  3. #3
    Sencha User
    Join Date
    Sep 2018
    Location
    Earth
    Posts
    2

    Default

    Quote Originally Posted by aallord View Post

    You can go from the field, working up to the grid, the store, the selection model, and then the selection.

    Code:
    field.up('grid').getView().getSelectionModel().getSelection();
    Very interesting, thank you!
    But unfortunately, when i select a cell ('textfield'), the record doesn't seem to be selected, therefore doesn't show up in getSelectionModel(). And i couldn't find an identifier (like xtype or id) of the selected row...

    My solution now is a for-loop, checking the content of the edited cell in modified records with field.value. It's not pretty, but at least better than the ownerCt approach.

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892
    Answers
    41

    Default

    The field has ownerCt which is the Editor. That's not well documented.

    That has a context property which contains the full editing context. Not well documented either. This is the kind of query which should spur a quick update to the doc comments for next release...

Similar Threads

  1. [FIXED] Event parameter missing in Text field clearicontap action
    By aumnia in forum Sencha Touch 2.x: Bugs
    Replies: 2
    Last Post: 22 May 2015, 5:44 AM
  2. Replies: 2
    Last Post: 31 Jan 2012, 3:23 AM
  3. Combobox reverting to first record after 'select' event listener fires
    By ALEITZ in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 6 Feb 2011, 6:48 AM
  4. Replies: 2
    Last Post: 22 Oct 2009, 11:25 PM

Tags for this Thread

Posting Permissions

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