【问题标题】:Sencha nested list with html buttonSencha 带有 html 按钮的嵌套列表
【发布时间】:2013-12-13 12:21:00
【问题描述】:

我对煎茶很陌生。我的要求是在嵌套列表中添加一个 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 以进行进一步处理,然后在处理完成后刷新嵌套列表。

提前致谢

【问题讨论】:

    标签: sencha-touch


    【解决方案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>');
    }
    
    }, 
    

    【讨论】:

    • 如果单击 SomeID,如何停止导航到详细信息卡?我尝试了 SuspendEvents(false) 并返回 false 但没有喜悦。我希望如果单击 SomeID 按钮,它应该保留在嵌套列表中并发布到 web api 并更新记录并刷新列表。在列表上正常点击切换到详细信息卡。提前致谢
    • 嗨 Dibish,如果单击按钮并停留在同一个嵌套列表页面上,如何停止项目点击事件?详情请参考我之前的评论。谢谢
    猜你喜欢
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-10
    • 2012-10-25
    • 2013-07-30
    相关资源
    最近更新 更多