-
11 Aug 2009 5:23 AM #1
DataView Template with button
DataView Template with button
Hi I Have a Template for a DataView :
Now ic want to fetch the button in oder to catch an event with Ext.get('delete-button') but it always says Ext.get('delete-button') is nullHTML Code:var tpl = new Ext.XTemplate( '<tpl for=".">', '<div id="{id}" class="thumb-wrap" >', '<p><br>[B]<input type="button" id="delete-button" value="delete" />[/B]', '<input type="radio" name="is_startbild" value="{id}" {is_startbild}></p>', '<div class="thumb"><img src="../services.php?{url}" title="{name}" width=80></div>', '</div>', '</tpl>', );
Thanks for help
-
11 Aug 2009 5:31 AM #2
As usual. Add a click handler to the DataView. Test the target of the event in the listener to see if it took place in a button.
Of course, you know DOM IDs must be unique? Don't you?Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
11 Aug 2009 5:50 AM #3
yes I know with the unique Id:
here is my code nothing happens:
Code:BilderTemplate = Ext.extend(Ext.DataView, { initComponent: function(){ var store = new Ext.data.JsonStore({ url: '../services.php?class=EventService&method=getFiles', fields: ['id', 'url', 'name', 'is_startbild'], root: 'data' }); var tpl = new Ext.XTemplate( '<tpl for=".">', '<div id="{id}" class="thumb-wrap" >', '<p><br><input type="button" id="delete-bild-button" value="löchen" />', '<input type="radio" name="is_startbild" value="{id}" {is_startbild}></p>', '<div class="thumb"><img src="../services.php?{url}" title="{name}" width=80></div>', '</div>', '</tpl>', ); Ext.apply(this, { store: store, tpl: tpl, multiSelect: false, singleSelect: true, overClass:'x-view-over', itemSelector:'div.thumb-wrap', emptyText: 'Keine Bilder vorhanden', handler: function(a, b, c){ debugger; }, listeners: function(a, b, c){ debugger; } }); BilderTemplate.superclass.initComponent.apply(this,arguments); } // eo function initComponent });
-
11 Aug 2009 7:07 AM #4
Looks like you don't. For each item you have
DO NOT extend to configure.Code:id="delete-bild-button"
It's a copy+pasted way of avoiding writing code. You hoiked it once out of somewhere you got code from, and then never thought about the issue again.
listeners CAN NOT be added in initComponent.
And anyway, have you ever added listeners using that object format? Ever?
What events? YOU have added listeners before, so yuo DO know how to do it. You're just flapping.Code:listeners: function(){...}Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
10 Apr 2013 11:23 AM #5
How to "Test the target "
How to "Test the target "
Hi Animal. I'm working with an dataview and I also want to add a delete button. I've done as you suggested, yet I don't know how to "Test the target" to see if the button fired the event. The onPictureViewSelect function dataViewModel, record, and options as parameters. How do I test for the button click?
Can you point me in the right direction, please?
Many thanks in advance.
Here is my code:
onPictureViewSelect:Code:{ xtype: 'dataview', border: 1, frame: true, itemId: 'pictureView', autoScroll: true, emptyText: 'No Images', itemSelector: 'div.thumb-wrap', itemTpl: [ '<div id="{ID}" class="thumb-wrap" >', ' <p><br><input type="button" id="delete-button{ID}" value="delete" /> ', ' <div class="thumb"><img src="images/{PICTURE}" title="{PICTURE}" width=200></div>', '</div>' ], overItemCls: 'x-item-over', store: 'pictureStore', trackOver: true, listeners: { select: { fn: me.onPictureViewSelect, scope: me } } }
Code:onPictureViewSelect: function(dataviewmodel, record, eOpts) { Ext.Msg.alert('Status', 'Changes saved successfully.'); },-Hector Cervantes
GIS Pro


Reply With Quote