对Sencha中的List中的特定项执行某些操作

时间:2012-06-23 07:27:07

标签: sencha-touch-2

问题我面临的是当我点击删除按钮时,我无法从列表中删除任何行或多行。这是我的代码:

    {
        xtype: 'list',
        store: "Plays",
        itemId:"playsList",
        mode: 'MULTI',
        loadingText: "Loading PlaysList...",
        emptyText: '<div class="notes-list-empty-text">No PlayList found.</div>',
        itemTpl: '<div class="list"><div class="list-item-title">{title}</div><div class="list-item-narrative">{duration}</div><div class="list-item-hide">{hidden}</div></div>',      
        itemSelector: 'div.list',

   },
    {
                    xtype: "button",
                    iconCls: "trash",
                    iconMask: true,
                    itemId: "deleteButton"
            },

   onDeleteButtonTap: function () {
        //console.log("deleteNoteCommand");//How to get value of recored from playlist

    this.fireEvent("deleteNoteCommand", this);
},

现在我选择任何行并单击“删除”按钮,然后如何获取所选项目或行的值并通过点击按钮执行某些操作。 就像在这里,我正在删除所选行 控制器

  Ext.define("PlayListApp.controller.Plays", {
      extend: "Ext.app.Controller",
    config: {
         refs: {
        // We're going to lookup our views by xtype.
        notesListView: "playslistview",
         notesList: "#playsList",
  },
  },
   onDeleteNoteCommand: function () {
      console.log("onDeleteNoteCommand");

    var noteEditor = this.getNotesList();
    console.log(noteEditor);
    }

1 个答案:

答案 0 :(得分:1)

当您在列表记录中选择后点击按钮时,您可以使用以下代码

获取所选列表的记录
  var record= this.getNotesList().getSelection()[0];

此代码为您提供所选记录,之后您可以使用以下代码从商店中删除记录

this.getNotesList().getStore().remove(record);//bracket in here too....