Results 1 to 2 of 2

Thread: Deleting data from the server

  1. #1
    Ext User
    Join Date
    Sep 2009
    Posts
    10

    Default Deleting data from the server

    Hi,
    I am learning from Learning-Extjs 2.0 book. The deleting data not working. I can't figure it out. It only works when i change to "client side remove" id: e.record.id to id: sel.data.id in tbar.

    Note: I use the php code provided in learning-extjs 2.0
    Need help thx

    Chapter 6 (editor grids)
    part - deleting data from the server

    This is the listeners inside EditorGridPanel
    Code:
    listeners: {
        afteredit: function (e) {
            var conn = new Ext.data.Connection();
            conn.request({
                url: 'movies-update.php',
                params: {
                    action: 'update',
                    id: e.record.id,
                    field: e.field,
                    value: e.value
                },
                success: function (resp, opt) {
                    e.commit();
                },
                failure: function (resp, opt) {
                    e.reject();
                }
            });
        }
    }


    And here is the handler under tbar remove button
    Code:
    {
        text: 'Remove Movie',
        icon: 'images/table_delete.png',
        cls: 'x-btn-text-icon',
        handler: function () {
            var sm = grid.getSelectionModel();
            var sel = sm.getSelected();
            if (sm.hasSelection()) {
                Ext.Msg.show({
                    title: 'Remove Movie',
                    buttons: Ext.MessageBox.YESNOCANCEL,
                    msg: 'Remove ' + sel.data.title + '?',
                    fn: function (btn) {
                        if (btn == 'yes') {
                            var conn = new Ext.data.Connection();
                            conn.request({
                                url: 'movie-update.php',
                                params: {
                                    action: 'delete',
                                    id: e.record.id
                                },
                                success: function (resp, opt) {
                                    grid.getStore().remove(sel);
                                },
                                failure: function (resp, opt) {
                                    Ext.Msg.alert('Error', 'Unable to delete movie');
                                }
                            });
                        }
                    }
                });
            };
        }
    }

  2. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364

    Default

    What is "e.record.id"??

    it should be sel.data.id

Posting Permissions

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