[CLOSED] Grid Error

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Grid Error

    I am using a grid in an MVC (Razor) app with the rowEditing plugin. On the first page, there is no problem with editing. However, on other pages, when going into edit mode, I receive this error:

    "context is undefined"

    The debugger points me to this source:
    if (me.beforeEdit(context) === false || me.fireEvent('beforeedit', me, context) === false || context.cancel || !me.grid.view.isVisible(true)) {
    return false;
    }
    (here's a broader look)
    beforeEdit: Ext.emptyFn,
    startEdit: function(record, columnHeader) {
    var me = this,
    context = me.getEditingContext(record, columnHeader);
    if (me.beforeEdit(context) === false || me.fireEvent('beforeedit', me, context) === false || context.cancel || !me.grid.view.isVisible(true)) {
    return false;
    }
    me.context = context;
    me.editing = true;
    },
    I do have listeners on the rowEditing plugin, but I don't have a "BeforeEdit." I am retrieving the data via a proxy, but I have remote paging set to false, so I am unsure why editing on page 2-n would be any different than page 1.

    Any ideas or hints as to why this error is presenting?
    Last edited by Daniil; Aug 02, 2012 at 3:13 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I am unable to reproduce. Please provide a test sample.
  3. #3
    I have a bit more detail which may help.

    I have a column in the grid with buttons. One of the buttons fires off the editing command. The script for that is:

    function gridCommandClick(caller, row) {
        App.TeamGrid.editingPlugin.startEdit(row.index, 0);
    That fails. However, simply double-clicking the row works. Am I calling the startEdit incorrectly?
    Last edited by Daniil; Aug 01, 2012 at 6:22 PM. Reason: Please use [CODE] tags
  4. #4
    I have a bit more information...

    In my function, I pass the row.index. If I view that number, it may be 33. When I then do something like:
    App.TeamGrid.store.getAt(33)
    , I received an "undefined." Further, I see that even though I may be on page 2 and on row #36, the "getAt" may wind up being 2. This isn't at all what I would have expected. In fact, even though my store has 406 records, if I "getAt" anything larger than my page size index(currently pagesize=15) I receive "undefined." However, if I use:
    App.TeamGrid.store.allData.getAt(row.index)
    , I do get the correct row, but I don't know how to translate that to the rowEditing pluging to edit the actual row I am on in the grid. Hopefully, this is making sense.
  5. #5
    The getAt method expects an index within the current page.

    The startEdit method expects a record (not index) and a column to be passed as the arguments.
    http://docs.sencha.com/ext-js/4-1/#!...thod-startEdit
  6. #6
    I have reviewed the link. I don't know how I came upon the original javascript, but it was somewhere searching throught the forum or examples. At any rate, the link was helpful except it wasn't clear about the "column" part (the page has "columnheader" which is really confusing). Here is the code I landed on:
    App.TeamGrid.editingPlugin.startEdit(App.tmStore.allData.getAt(row.index), 0);
    So far, it seems to work. I did try passing in my "column" (App.teamName), but the script balked at that. However, the column index seems like it works. Still, if there is something better (or more accurate) that I should be doing, please let me know. Other than that, we can mark the thread closed.


    Thanks.
  7. #7
    I have discovered that the startEdit method can apply indexes for the both arguments. Just it's not documented.

    So, the following works:
    editingPlugin.startEdit(0, 0);
    The second "column" argument means a column editor which will be initially focused in the row editor.
  8. #8
    So, the following works:

    Code:
    1 editingPlugin.startEdit(0, 0);
    The second "column" argument means a column editor which will be initially focused in the row editor
    Be careful with that, because that is what was giving me an issue and prompted this thread. The code above DOES work for a grid with no pagination or a paginated grid on page 1. It breaks on grids pages 2-n. It seems that the reason why is because the index on page 2, row 3 (as an example) is not necessarily the index of the store record. I think you need the index of the store record in order for this to actually work.
  9. #9
    Please clarify what is the "row" here?
    function gridCommandClick(caller, row)
  10. #10
    Sure. "Row" is passed via a listener from a command button:
    Dim btn2 As New Ext.Net.GridCommand()
     With btn2
    .Text = "Cedents"
    .Icon = Icon.None
    .CommandName = "ManageCedents"
    .StandOut = True
    End With
                                                                                                                        
    commands.Add(btn2)
    End Sub).Listeners(Sub(lstnrs)
    lstnrs.Command().Handler = "gridCommandClick(command,record);"
    End Sub) _

    Actually, passing "row" in instead of row.index does work, but as stated, the example for the rowEditing I found had indicies. When, I was tracing through the issue, the row.index value I was getting was the index of the row(record) as it pertains to its position on a given page. So, on an item on page 2, row 3, the index would return 2. However, what I needed to pass (given a pageSize of 20) was 21 (at least that is what I am assuming will work).
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Grid Error Handling
    By adelaney in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 11, 2012, 8:37 PM
  2. [CLOSED] this.grid.stopEditing error
    By Marcelo in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Sep 15, 2011, 3:46 PM
  3. [CLOSED] Error 500 saving grid store
    By harafeh in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 30, 2009, 2:59 PM
  4. [CLOSED] ComboBox in grid error
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Apr 23, 2009, 4:41 AM
  5. [CLOSED] Grid Panel runtime error...
    By speedstepmem2 in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Jan 12, 2009, 8:58 AM

Tags for this Thread

Posting Permissions