JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">
<script src="http://www.jeasyui.com/easyui/jquery.min.js"></script>
<script src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<link rel="stylesheet" href="http://www.jeasyui.com/easyui/demo/demo.css">
<div style="width:700px;">
<div class="left">
<table>
<tr>
<td>
<div class="item">English</div>
</td>
</tr>
<tr>
<td>
<div class="item">Science</div>
</td>
</tr>
<tr>
<td>
<div class="item">Music</div>
</td>
</tr>
<tr>
<td>
<div class="item">History</div>
</td>
</tr>
<tr>
<td>
<div class="item">Computer</div>
</td>
</tr>
<tr>
<td>
<div class="item">Mathematics</div>
</td>
</tr>
<tr>
<td>
<div class="item">Arts</div>
</td>
</tr>
<tr>
<td>
<div class="item">Ethics</div>
</td>
</tr>
</table>
</div>
<div>
<table id='dgTest' class='easyui-datagrid'>
<thead>
<tr>
<th data-options="field:'times'"></th>
<th data-options="field:'Monday', styler:setDrop">Monday</th>
<th data-options="field:'Tuesday', styler:setDrop">Tuesday</th>
<th data-options="field:'Wednesday', styler:setDrop">Wednesday</th>
<th data-options="field:'Thursday', styler:setDrop">Thursday</th>
<th data-options="field:'Friday', styler:setDrop">Friday</th>
</tr>
</thead>
<tbody>
<tr>
<td class="time">08:00</td>
<td class="drop"></td>
<td class="drop"></td>
<td class="drop"></td>
<td class="drop"></td>
<td class="drop"></td>
</tr>
<tr>
<td class="time">09:00</td>
<td class="drop"></td>
<td...
CSS
.left {
width: 120px;
float: left;
}
.left table {
background: #E0ECFF;
}
.left td {
background: #eee;
}
.right {
float: right;
width: 570px;
}
.right table {
width: 100%;
}
.right td {
background: #fafafa;
color: #444;
text-align: center;
padding: 2px;
}
.right td {}
.drop {
background: #fafafa;
width: 100px;
}
.over {
background: #FBEC88;
}
.item {
text-align: center;
border: 1px solid #499B33;
background: #fafafa;
color: #444;
width: 100px;
}
.assigned {
border: 1px solid #BC2A4D;
}
.trash {
background-color: red;
}
JavaScript
$(function() {
initDragDrop()
});
function initDragDrop() {
$('.left .item').draggable({
revert: true,
proxy: 'clone'
});
$('.drop').droppable({
onDragEnter: function() {
$(this).addClass('over');
},
onDragLeave: function() {
$(this).removeClass('over');
},
onDrop: function(e, source) {
$(this).removeClass('over');
if ($(source).hasClass('assigned')) {
$(this).append(source);
} else {
var c = $(source).clone().addClass('assigned');
$(this).empty().append(c);
c.draggable({
revert: true
});
console.log($('#dgTest').datagrid('getRows'))
}
}
});
$('.left').droppable({
accept: '.assigned',
onDragEnter: function(e, source) {
$(source).addClass('trash');
},
onDragLeave: function(e, source) {
$(source).removeClass('trash');
},
onDrop: function(e, source) {
$(source).remove();
}
});
}