Results 1 to 4 of 4

Thread: Changing store from an action

  1. #1
    Sencha User
    Join Date
    Feb 2010
    Posts
    82
    Answers
    2

    Default Changing store from an action

    Hi all,

    I think I have a simple problem, but I'm to silly to solve it ^^.
    I have an actioncolumn in an gridpanel that is provided by an MVC-structure with a store.

    The definition of the column is:
    Code:
    {
                        xtype: 'actioncolumn',
                        text: 'prfen',
                        width: 45,
                        align: 'center',
                        items: [
                            {
                                handler: function(view, rowIndex, colIndex, item, e, record, row) {
                                    
                                                var today = new Date();
                                                var dd = today.getDate();
                                                var mm = today.getMonth()+1; //beacuse January would be 0
                                                var yyyy = today.getFullYear();
                                                if (dd<10) {
                                                    dd = '0'+dd;
                                                }
                                                today = yyyy + '-' + mm + '-' + dd;
                                                view.getStore().getById(record.data.id).data.referenzecho_lastchange = today; 
                                                view.getStore().fireEvent('datachanged',{});
                                                view.getStore().commitChanges();
                                                view.getStore().sync();
                                                view.refresh();
                                },
                                icon: 'extjs/examples/desktop/images/gears.png',
                            }
                        ]
                    },
    I simply want to change a field of the actual record of the store to the current date. But I cant get the store save my changes. What's my problem here?`I dont understand it.

    Thank a lot,
    Tobias

  2. #2
    Sencha Premium User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    579
    Answers
    67

    Default

    You shouldn't need to refresh your view or fire datachanged manually. Don't modify record.data manually. Use the record.set method.

  3. #3
    Sencha User
    Join Date
    Feb 2010
    Posts
    82
    Answers
    2

    Default

    Thanks. It works now with this code:

    Code:
    record.beginEdit();
    record.set('referenzecho_lastchange', today);
    record.endEdit();

  4. #4
    Sencha Premium User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    579
    Answers
    67

    Default

    If you are only setting one field, I don't see a purpose in using beginEdit and endEdit.

Posting Permissions

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