ExtJS.Ext.data.DirectStore отправляет нулевые данные на сервер после обновления сетки - PullRequest
1 голос
/ 10 декабря 2010

У меня проблема с сохранением данных из Ext.data.DirectStore на сервер

Вот мой код:

new Ext.data.DirectStore({
    api: {
        read: AbonApi.cities,
        create: AbonApi.cities_create,
        update: AbonApi.cities_update,
        destroy: AbonApi.cities_destroy
    },
    paramsAsHash: false,
    autoSave: false,
    storeId: 'cities-store',
    reader: new Ext.data.JsonReader({
        root: 'data',
        idProperty: 'id',
        fields: [
            'id',
            'name',
            'label',
            'comment',
        ]
    }),
    writer: new Ext.data.JsonWriter({
        encode: true,
        writeAllFields: true,
        listful: true
    })
});

Ext.ux.CityGrid = Ext.extend(Ext.grid.EditorGridPanel,{
    initComponent: function(){
        var config = {
            frame:true,
            title: 'Cities',
            height:200,
            width:500,
            store: 'cities-store',
            closable: true,
            tbar: [{
                text: 'Apply',
                handler: function() {
                    this.store.save()
                },
                scope: this
            }],
            columns: [
                {header: "Id", dataIndex: 'id', editor: new Ext.form.TextField()},
                {header: "Name", dataIndex: 'name', editor: new Ext.form.TextField()},
                {header: "Label", dataIndex: 'label', editor: new Ext.form.TextField()},
                {header: "Comment", dataIndex: 'comment', editor: new Ext.form.TextField()},
            ],
            onRender:function() {
                Ext.ux.CityGrid.superclass.onRender.apply(this, arguments);
                this.store.load();
            }
        }
        Ext.apply(this, Ext.apply(this.initialConfig, config));
        Ext.ux.CityGrid.superclass.initComponent.apply(this, arguments);
    }
});

После редактирования сетки, нажав кнопку Apply, я вижу в firebug такие данные POST:

{"action":"AbonApi","method":"cities_update","data":null,"type":"rpc","tid":7}

Почему data равно нулю и где мои изменения в сетке? Я делаю что-то не так или это ошибка

ОБНОВЛЕНИЕ:

Ext.ux.CityGrid
... cutted out ...

        tbar: [{
            text: 'Apply',
            handler: function() {
                modified = this.store.getModifiedRecords();
                console.log(modified)                   
                this.store.save()
            },
            scope: this
        }],

... cutted out ...

Я вижу измененные данные в консоли перед сохранением хранилища. и эти данные не передаются на сервер;

1 Ответ

1 голос
/ 13 декабря 2010

Установите «кодировать: ложь» для JsonWriter. Проверено на создание и уничтожение. Я нашел это там: http://www.sencha.com/forum/showthread.php?80958-DirectStore-and-write-function

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...