-
19 Mar 2013 8:30 AM #1
Unanswered: make dataview dynamic elements draggable
Unanswered: make dataview dynamic elements draggable
I have a dataview that is populated using a store and template so the process is dynamic. I then want to make each of the container Divs (see template) draggable and use the following code. I would have expected just the container divs(image + name) to be draggable but instead the whole DataView is draggable. Was wondering what i am doing wrong?
Code:Ext.define('MyApp.view.allImages', { extend: 'Ext.dataview.DataView', xtype: 'cams', requires: [ 'MyApp.store.images' ], config: { title: 'Test', store: 'images', baseCls: 'camera-list', itemTpl: [ '<div id="camimage">', '<div class="image" style="background-image:url({fullimage})"></div>', '<div class="name">{address}</div>', '</div>' ].join(''), records: null, items: [ { xtype: 'toolbar', docked: 'top', title: 'Gainesville' }, { xtype: 'toolbar', docked: 'bottom', items: [ { xtype: 'button', text: 'Path1' }, { xtype: 'button', text: 'Path2' }, { xtype: 'button', text: 'Path3' } ] } ] }, initialize: function () { this.callParent(arguments); //get the divs that we want to make draggable var images = this.element.select("div[id='camimage']"); Ext.each(images.elements, function (imageElement) { imageElement.draggable = true; }); }
-
21 Mar 2013 5:33 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,121
- Vote Rating
- 453
- Answers
- 3161
Just doing
won't do anything. You can try to create Ext.util.Draggable passing in the element you want draggable. Looking at the source there is an element config.Code:imageElement.draggable = true;
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
21 Mar 2013 7:22 AM #3
I tried the following code with the same result, the entire dataview is draggable I also checked the imageElement and it looks correct as it contains my HTML:
Code:Ext.each(images.elements, function (imageElement) { imageElement.draggable = new Ext.util.Draggable({ element: imageElement, listeners: { dragstart: function (self, e, startX, startY) { console.log("test dragStart[" + startX + ":" + startY + "]"); }, drag: function (self, e, newX, newY) { console.log("test drag[" + newX + ":" + newY + "]"); }, dragend: function (self, e, endX, endY) { console.log("test dragend[" + endX + ":" + endY + "]"); } } }); });
-
24 Mar 2013 11:02 AM #4
There are actually 2 problems here 1) the whole containing DataView moving was solved by setting the scrollable config on the dataview to false. of course this has huge side-effects but another battle as I think the Sencha draggable code is a little weak as one needs to scroll and drag. 2) I changed the select to:
var images = this.element.select("div[class='image']");
as a static Id cannot be used in this case and the class solves the issue


Reply With Quote