0

SenchaArchitectでExtJs4.1を使用する。

onDeleteButtonコードに次のコードがあります

onDeleteButtonClick: function(button, e, options) {
     var active = this.activeRecord;
     var myGrid = Ext.getCmp('publisherResultsGridView'),
         sm = myGrid.getSelectionModel(),
         selection = sm.getSelection(); // gives you a array of records(models)

     if (selection.length > 0){
            for( var i = 0; i < selection.length; i++) {
                            this.application.log('OnDeleteItemID is ' + selection);
            }
            this.remove(selection);
     }

Remove関数のコード

remove: function(record) {
        var store = Ext.getStore('PublisherProperties');
        store.proxy.url = MasterDataManager.globals.url + "Publishers/";
        store.remove(record);
        store.sync();

実行すると、ログにオブジェクトの配列が表示されます。また、remove関数の実行後にエラーが発生することもありません。ただし、ストアは更新されません。つまり、選択したアイテムは削除されません。

誰か助けてくれませんか。

ありがとう

4

1 に答える 1

1

以下の変更を加えて問題を解決しました。

onDeleteButtonClick

if (selection.length > 0){
                for( var i = 0; i < selection.length; i++) {
                                this.application.log('OnDeleteItemID is ' + selection[i].data.id);
                                this.remove(selection[i]);
                }

         }

Remove機能するには

remove: function(record) {
    var store = Ext.getStore('PublisherProperties');
    this.application.log('Remove Function is ' + record);
    store.proxy.url = MasterDataManager.globals.url + "Publishers/" + record.data.id;
    store.load({
                        scope : this,
                        callback : function(records, operation, success){
                            if (records.length > 0){
                                var store2 = Ext.getStore('PublisherProperties');
                                        store2.proxy.url = MasterDataManager.globals.url + "Publishers/";
                                        store2.remove(records[0]);
                                        store2.sync();
                             }
                        }
            });
    //store.remove(record);
    //store.sync();
于 2013-01-14T23:34:37.210 に答える