Results 1 to 4 of 4

Thread: Saving grid data on row change and focus lost

  1. #1

    Default Saving grid data on row change and focus lost

    jack suggested (wisely) that i move this here to see if the community at large has any ideas on how to handle the situation...

    OK, so the way i have things set up (mostly because of my possible misunderstanding of how the cell selection model works in the editor grid) is that my changes to data in the grid is triggered by the afterCellEdit event. However, this results in a very "chatty" model in which i'm constantly sending updates to the server when the user switches cells (ick)...

    I'd like to be able to instead just commit changes when the user changes rows, or when the entire grid loses focus (which currently seems to trigger the afterCellEdit event).

    Unfortunately I'm at a loss as to how to implement this change, so...

    • Has anyone here done this already? If so, how did you solve this problem?
    • Would replacing the CellSelectionModel with RowSelectionModel make a diffrerence, or would it just lead to more complications?
    • Is there an alternate solution that I'm just missing here?

    evan k. stone | santa rosa, ca
    Ext v1.1.1 | FF 2.0.0.x | IE 6.0 | Safari 2.x/3.x (Mac & Win) | WebKit Mac (+ Drosera)

  2. #2


    The CellSelectionModel cellselect event gives you the row index, you could have a variable with the last modified row and if a new row is selected (or the entire container loses focus), comit.

    Another option is to give a button to the user where he can commit every dirty field and send all at once.

  3. #3


    funny you should mention that about keeping track of the row id - i was just thinking about doing that as i was making my lunch (solutions just seem to pop up that way it seems)...

    so what i was mulling over was the use cases here, and it seems that there are three cases to consider:

    1. user moves to a new cell
    2. user moves to a new row
    3. user changes focus from grid to a different control

    ...i think I can handle 1 & 2 using a method similar to what zafiro describes by checking to see if the user has changed rows using cellselect, and if so, commit the old one.

    it's number three that puzzles me now.

    what's the standard way of trapping if the grid has lost focus? i didn't think i could just trap an onblur event, so what should i use instead (or is that in fact what i should be looking at)? it's obvious that the grid & editors are reacting to the loss of focus, but it's not clear to me just how that's happening...
    evan k. stone | santa rosa, ca
    Ext v1.1.1 | FF 2.0.0.x | IE 6.0 | Safari 2.x/3.x (Mac & Win) | WebKit Mac (+ Drosera)

  4. #4
    Ext JS Premium Member
    Join Date
    Sep 2007

    Default Grid commit cellchange / grid blur

    Here is how I went about doing this for an editor grid in V3. I understand the original question was regarding v1.1 and at the time this may not have been possible.

    I don't have this tied to an ajax post request it would probably get kind of chatty if you did this with alot of grid and cells. This takes care of committing the records even if the user clicks somewhere else other than the grid on the form.

    However i'm using it to populate a grid in a form which requires that other parts of the form be filled out and finally a form submit button is pressed in the end which captures all the elements on the form including all the grid values and submits them to the server.

    I also found that this doesn't work for the custom checkColumn that's used in the examples, still trying to figure out how to make this work for the checkColumns. If anyone has this working for checkColumns please share.


    function aftereditCompanies(e)
    grid - This grid
    record - The record being edited
    field - The field name being edited
    value - The value being set
    originalValue - The original value for the field, before the edit.
    row - The grid row index
    column - The grid column index


Posting Permissions

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