Sencha用html按钮嵌套列表

时间:2013-12-13 12:21:00

标签: sencha-touch

我对Sencha很新。我的要求是在嵌套列表中添加一个html按钮,将每个项目发布到Web API。

{
              xtype: 'nestedlist',
              title: 'Jobs',
              iconCls: 'star',

              getItemTextTpl: function (node) {
                  return '<div style="float:left">{text}</div><div style="float:right"> 
                      '<input type="button" title="xyz" value="pqr"  id="someID"/></div>';


              },


              store: {
                  type: 'tree',

                  fields: [
                      'text', 'id', 'name', 'title',
                      { name: 'leaf', defaultValue: true }
                  ],

                  root: {
                      leaf: false
                  },

                  proxy: {
                      type: 'rest',
                      url: 'http://localhost/AD/api/jobs/',
                      reader: {
                          type: 'json',
                          //  rootProperty: 'root'
                      }
                  }
              },

              detailCard: {
                  xtype: 'panel',
                  scrollable: true,
                  styleHtmlContent: true
              },

              listeners: {
                  itemtap: function (nestedList, list, index, element, post) {
                      debugger;
                      this.getDetailCard().setHtml('<pre><h4>Log</h4>' + post.get('AuditLog') + '</pre>');
                  },                    

              }

我想将事件监听器附加到“SomeID”按钮,以便将项目发布到Web api进行进一步处理,然后在处理完成后刷新嵌套列表。

提前致谢

1 个答案:

答案 0 :(得分:1)

请尝试

    listeners: {
                      itemtap: function (nestedList, list, index, element, post,e) {
                         if (e.getTarget(someID)){
                                // do something here in button tap
                         }
                          else{
                          this.getDetailCard().setHtml('<pre><h4>Log</h4>' + post.get('AuditLog') + '</pre>');
}

}, 
相关问题