[CLOSED] Multiple javascript action in handler without grid store update

  1. #1

    [CLOSED] Multiple javascript action in handler without grid store update

    Hello,

    I am trying to manipulate a couple of store/grid records that have a filter. If I change now something the filter updates the grid instantly and the saved indexes lead to wrong manipulations of other records. Is there a way to stop the auto update in the beginning, do my javascript tasks and then update the grid? I have seen that the row editor plugin uses something like cancelEdit and startEdit but I am not sure if that is what I am looking for and I don't use that plugin.

    Thanks for pointing me in the right direction.

    best regards
    Last edited by Daniil; May 05, 2015 at 3:41 PM. Reason: [CLOSED]
  2. #2
    Hi @tMp,

    If I change now something
    Please demonstrate what and how you change.

    Do you use a record's .set() method? If so, you might need to use:
    http://docs.sencha.com/extjs/5.1/5.1...thod-beginEdit
    http://docs.sencha.com/extjs/5.1/5.1...method-endEdit
    http://docs.sencha.com/extjs/5.1/5.1...hod-cancelEdit

    Or deal with a record's data directly:
    record.data.someField = "new value";
  3. #3
    Hello @Daniil,

    Yes you are right, I am using the .set(). What I am doing:

    I have a button in the toolbar that sets one field of a record to true. But there can only be one single record where that field is true so I have to delete it in another record if it is set somewhere.

    So first I am saving the index of the row selected
    .indexOf(.....getSelection()[0])
    then I am using
    .findRecord(Col_name, true)
    and then I am setting it to false
    .set(Col_name, false)
    after that I would like to set the original selected record to true on this column
    .set(col_name, true)
    but because there is a filter on the grid the rows switch after the first .set() and then the stored index is wrong.

    UPDATE
    It is working flawlessly with yout tip about "record.data.xxx" and then doing a "grid.getView().refresh()"!

    Just for my curiousity though:
    Did I get it right, that the beginEdit() is only for a model? Though I should set it for both records that I want to change, do the changes and then endEdit() for both again? Or is there a way to do the edit for the whole store?

    Thank you very much!
    Last edited by tMp; Apr 25, 2015 at 1:57 PM.
  4. #4
    Did I get it right, that the beginEdit() is only for a model?
    Yes, for a `Ext.data.Model` instance which we usually call `record`.

    Though I should set it for both records that I want to change, do the changes and then endEdit() for both again?
    Yes, that is right.

    Or is there a way to do the edit for the whole store?
    I don't see such a thing in API. You might want to create a couple of helper utility functions. One of them would call .beginUpdate() on each record of Store, another would call .endUpdate() also on each.

Similar Threads

  1. Insert and update grid record from Javascript
    By SaleCar in forum 3.x Help
    Replies: 1
    Last Post: Apr 27, 2015, 6:20 PM
  2. [CLOSED] Multiple partialview replacement in a single action
    By ATLAS in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 18, 2013, 4:50 AM
  3. [CLOSED] Javascript - Update a Grid
    By adelaney in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 19, 2012, 6:27 PM
  4. Replies: 1
    Last Post: Dec 22, 2011, 6:17 AM
  5. Replies: 2
    Last Post: Aug 05, 2010, 3:50 PM

Posting Permissions