JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://cdn.sencha.com/ext-4.1.1-gpl/resources/css/ext-all.css">
CSS
.data-view-wrap {
padding: 5px;
}
.data-view-wrap div {
line-height: 50px;
text-align: center;
overflow: hidden;
background: pink;
}
JavaScript
var store;
Ext.onReady(function () {
var view, data;
data = [
{ id: 1 },
{ id: 2 },
{ id: 3 }
];
store = Ext.create('Ext.data.Store', {
fields: ['name'],
data: data
});
Ext.create('Ext.Panel', {
width: 400,
height: 300,
autoScroll: true,
renderTo: Ext.getBody(),
title: 'Simple DataView',
bodyPadding: 5,
tbar: {
items: [{
text: 'empty',
handler: function () {
store.removeAll();
}
}, {
text: 'add',
handler: function () {
var count = store.getCount();
store.add({ id: ++count }, { id: ++count }, { id: ++count });
}
}, {
text: 'reset',
handler: function () {
if (store.getCount() !== 3) {
store.removeAll();
store.add(data);
}
}
}]
},
items: view = Ext.create('Ext.view.View', {
store: store,
emptyText: 'Nothing to display',
itemSelector: '.data-view-wrap',
tpl: [
'<tpl for=".">',
'<div class="data-view-wrap">',
'<div>',
'<span>#{id}</span>',
'</div>',
'</div>',
'</tpl>',
'<div class="x-clear"></div>'
],
listeners: {
itemdblclick: function (view, record, item, index, e) {
if (Ext.get(e.getTarget()).is('span')) {
console.log('you clicked a span');
}
console.log(record.get('id'));
}
}
})
});
new Ext.view.DragZone({
view: view,
ddGroup: 'test',
dragText: 'test'
});
new Ext.view.DropZone({
view: view,
ddGroup: 'test',
handleNodeDrop : function(data, record, position) {
var view = this.view,
store = view.getStore(),
index, records, i, len;
if (data.copy) {
records = data.records;
data.records = [];
for (i = 0, len = records.length; i < len; i++) {
data.records.push(records[i].copy(records[i].getId()));
}
} else {
data.view.store.remove(data.records, data.view === view);
}
index = store.indexOf(record);
if (position !== 'before') {
index++;
}
store.insert(index,...