Girish Sakhare
Girish Sakhare

Reputation: 763

Sencha nested list with html button

I am quite new to Sencha. My requirement is to add a html button to the nested list each item that will post the selected item to 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>');
                  },                    

              }

I want to attach event listener to the button 'SomeID' so that the item should be posted to the web api for further processing and then refresh the nested list after the processing is done.

Thanks in advance

Upvotes: 0

Views: 199

Answers (1)

Dibish
Dibish

Reputation: 9303

Please try

    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>');
}

}, 

Upvotes: 1

Related Questions