-
2 Jul 2010 5:13 PM #1
How to embed a clickable button within a Ext.list view?
How to embed a clickable button within a Ext.list view?
I want to have each of my list elements to have a button. When the button is clicked it would fire some function (and passed in is the list entry that was clicked on's data model)
Right now I have this code:
this calls func but I would rather do this in a more object oriented way -- further more it does not capture the list items click event so that also fires... if the button is pressed i don't want the list item to be selected.Code:this.template = new Ext.XTemplate( '<tpl for="."><div class="location_entry"><strong>{[this.shorten(values["name"])]}</strong> {description} <p padding="4" align="right"><a onclick="func({#}-1,this)" class="medium button red">Test</a></p></div></tpl>',
Any help is greatly appreciated
-
2 Jul 2010 9:49 PM #2
Hi...
I figured it out. I am posting the solution (which isn't super elegant) here in case anyone has the same problem.
I wait until the Ext.List is rendered ... in the template I add a div with a prefix + the row of the list entry.
now I call this code once it is rendered:Code:this.template = new Ext.XTemplate( '<tpl for="."><div class="list_entry"><table width="100%"><tr><td><strong>{[this.shorten(values["name"])]}</strong> {description} </td><td align="right"><span id="button_{#}" ></span></td></tr></table></div></tpl>', { // member functions: shorten: function(name){ if(name.length<=24)return name; name = name.substring(0,22); name+="..."; return name; }, isSet: function(value){ return value!=null; } } );
Code:for(var i =1; i<=dataInput.length; i++){ var button = new Ext.Button({ maxWidth:70, text: 'Hop', ui:'drastic', handler: function(){ }, scope: parent }); button.render(document.getElementById("button_"+i)); }
-
2 Jul 2010 11:08 PM #3Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 43
Maybe something for the ComponentListView user extension?
-
5 Jul 2010 1:40 PM #4Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Haarlem, Netherlands
- Posts
- 1,235
- Vote Rating
- 5
Thanks for the feedback and solution. We are currently working on List improvements, and came we came up with something similar. We will add the capability to add buttons to list items (amongst other new features), so hopefully this workaround will not be needed anymore soon.
-
12 May 2011 1:07 PM #5
-
28 Jun 2011 10:32 AM #6
Similar question.
I want to inject a Button (and other form widgets) into a <table> generated by a DataView.
-
31 Jan 2012 4:12 AM #7
Buttons inside a list view?
Buttons inside a list view?
How to include buttons inside a list view?
Similar Threads
-
Clickable images inside a list
By davorin in forum Sencha Touch 1.x: DiscussionReplies: 4Last Post: 1 Jul 2010, 1:53 PM -
[UNKNOWN]Revision 5572/96 breaks examples/view/list-view.html
By meroy in forum Ext 3.x: BugsReplies: 22Last Post: 1 Nov 2009, 11:45 PM -
List view which behaves like windows explorer list view
By suvarnal in forum Ext GWT: Help & Discussion (1.x)Replies: 4Last Post: 9 Dec 2008, 5:39 AM -
clickable url in tree view
By tab in forum Ext 1.x: Help & DiscussionReplies: 4Last Post: 10 Mar 2007, 6:38 AM


Reply With Quote

