KeyPress on GridPanel

  1. #1

    KeyPress on GridPanel

    Hi,

    How can I know which key is pressed in a GridPanel?

    I want to get that key and scroll to the first row which first column strarts with this key.

    Thanks in advance,

    Dominik.
  2. #2
    Ok,

    Finally, I get it.

    For those interested in, this is the script code:

    var KeyPressHandler = function (e) {
        var c = e.getKey();
        var keyPressed = String.fromCharCode(e.getCharCode());
        var rowIndex = 0;
        var found = false;
        var store = gridVersiones.getStore();
        if (store.getCount() > 0) {
            store.each(function (record) {
                if (record.get('ObservacionesVersion').startsWith(keyPressed)) {
                    found = true;
                    return false;
                }
                rowIndex++;
            });
        }
        if (found) {
            gridVersiones.getSelectionModel().selectRow(rowIndex);
            gridVersiones.getView().focusRow(rowIndex);
        }
    }
    And here is how to call it from the GridPanel:

    <Listeners>
        <KeyPress Fn="KeyPressHandler" />                                                        
    </Listeners>
    Regards,

    Dominik.
    Last edited by Dominik; Feb 13, 2012 at 2:36 PM.

Similar Threads

  1. [CLOSED] don't works KeyPress
    By ViDom in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 19, 2011, 9:29 AM
  2. [CLOSED] keypress event
    By RomualdAwessou in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 18, 2011, 3:53 PM
  3. textfield keypress listeners
    By okutbay in forum 1.x Help
    Replies: 3
    Last Post: May 04, 2010, 2:39 AM
  4. [CLOSED] Handle enter keypress on gridpanel
    By jchau in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 23, 2010, 4:38 PM
  5. ENTER KeyCapture Keypress
    By Juls in forum 1.x Help
    Replies: 1
    Last Post: Nov 04, 2009, 9:19 AM

Posting Permissions