[CLOSED] Handling TAB event in GridPanel, getting certain record value and setting the selected record.

  1. #1

    [CLOSED] Handling TAB event in GridPanel, getting certain record value and setting the selected record.

    The below code is not working for me (MVC 4.1), please help!

    Html.X().NumberColumn().Text("Balance").Flex(1).Da taIndex("Balance").Align(Alignment.Right).Renderer (RendererFormat.UsMoney).TdCls("aquaBackground"),
    Html.X().NumberColumn().Text("Amount").Flex(1).Dat aIndex("comm_check_link_amount").Align(Alignment.R ight).Renderer(RendererFormat.UsMoney).
    Editor(Html.X().NumberField().Listeners(Sub(ls)
    ls.SpecialKey.Handler = "if (e.getKey() === e.TAB) calcNOAamount(recordIndex,record);"
    End Sub)),

    ---------------------------------------------------------

    var calcNOAamount = function (recordIndex, record) {
    debugger;
    App.NOA_Balance.setValue(record.data.comm_check_li nk_amount);

    };
    Last edited by fabricio.murta; Jan 21, 2017 at 3:06 PM. Reason: no user feedback for 7+ days
  2. #2
    Hello @mwiater!

    Please format and enclose your code between [code][/code] tags! It is very hard to read it the way you provided.

    What I can tell from what I could understand from your code is that you want to bind and edited value to another field outside the grid, so I believe you'd better off using the Edit event from your (I suppose) CellEditing plugin.

    Hope this helps! If not, please provide us a fully runnable sample code so we can further help you with the issue you are facing.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    I formatted the code (below). What I am trying to do is to update a cell in the grid with a value from another cell in the same grid when I hit TAB, but it's not working..

    Html.X().NumberColumn().Text("Balance").Flex(1).Da taIndex("Balance").Align(Alignment.Right).Renderer (RendererFormat.UsMoney).TdCls("aquaBackground"),
     Html.X().NumberColumn().Text("Amount").Flex(1).Dat aIndex("comm_check_link_amount").Align(Alignment.R ight).Renderer(RendererFormat.UsMoney).
     Editor(Html.X().NumberField().Listeners(Sub(ls)
     ls.SpecialKey.Handler = "if (e.getKey() === e.TAB) calcNOAamount(recordIndex,record);"
     End Sub)),
    
     var calcNOAamount = function (recordIndex, record) {
     debugger; 
     App.NOA_Balance.setValue(record.data.comm_check_li nk_amount);
    
     };
  4. #4
    Hello @mwiater!

    You don't mention what's wrong at all, and provide no test case, so I tried my best guess on your trouble by writing a test case with similar listener you provided and I could find that your listeners refers to non-existing recordIndex and record variables.

    This makes sense as the listener you added was for the number field, which is not really the cell, but a form field editor contained in that cell.

    To get the actual record from that context, you have to walk up/out in the component's context until you are in the cell.

    In the case, as far as I could infer, you are:
    1. on a grid panel
    2. on the grid itself
    3. on a row
    4. on a column
    5. on a cell
    6. inside an editor
    7. in a number field positioned and loaded for that given editor.

    Basically, to get the record all you need to do is look up one level from the number field, to get to the editor object. The editor object contains a context definition which in turn, will have the corresponding record to the cell being edited.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  5. #5
    I just want to get the value of a cell/record on the grid and set it to another cell/record when I hit TAB !!

    When debugging the code above I get: 'recordIndex' is undefined

    Can you help me with this or point me to someone who can? i.e. 2nd level support..
  6. #6
    Hello @mwiater!

    Use this as your special key handler:

    var rec = item.up().context.record; if (e.getKey() === e.TAB) calcNOAamount(rec.id, rec);
    Hope this helps.
    Fabrício Murta
    Developer & Support Expert
  7. #7
    Hello @mwiater!

    It's been some time since we posted a follow up to this thread and still no feedback from you. Did the instructions above work for you? We may mark this thread as closed in 7 business days or more but this won't mean you can't post additional follow ups as soon as you have time.

    Hope to hear again from you soon!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 3
    Last Post: Jun 17, 2015, 1:09 PM
  2. [1.0] Selected Record in a GridPanel
    By walle in forum 1.x Help
    Replies: 3
    Last Post: Nov 26, 2013, 1:34 AM
  3. GridPanel submit selected record
    By Qulei in forum 2.x Help
    Replies: 1
    Last Post: Nov 12, 2013, 4:22 AM
  4. Replies: 11
    Last Post: Oct 29, 2013, 5:32 PM
  5. How to get id of record for selected row in GridPanel?
    By Yanfang Wang in forum 1.x Help
    Replies: 2
    Last Post: Jun 13, 2010, 3:06 AM

Tags for this Thread

Posting Permissions