sortable datatables rows with updating in serverside
sortable datatables rows with updating in serverside
my datatables could fetch from server side, i want to sort that with seved order in database, below is simple code and i want to find start order text, stop order text to find witch orders must be change in database,in this code i cant find start order column
for example start order column is 1 with engine is HELLO and stop order is 4 with engine is WORLD , i want to change HELLO order to 4 and change WORLD order to 1,
[code]
$(document).ready(function() {
$('#datatable-wrapper').append('');
$('#example').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aaData": [
[ "1" , "HELLO", "----", "----", 0, "A" ],
[ "4" , "WORLD", "----", "----", 0, "A" ]
],
"aoColumns": [
{ "sTitle": "ORDER" },
{ "sTitle": "Engine" },
{ "sTitle": "Browser" },
{ "sTitle": "Platform" },
{ "sTitle": "Version", "sClass": "center" },
{
"sTitle": "Grade",
"sClass": "center",
"fnRender": function(obj) {
var sReturn = obj.aData[ obj.iDataColumn ];
if ( sReturn == "A" ) {
sReturn = "A";
}
return sReturn;
}
}
]
});
var startPosition;
var endPosition;
var start_id;
var end_id ;
$("#example tbody").sortable({
cursor: "move",
start:function(event, ui){
startPosition = ui.item.prevAll().length + 1;
var nTds = $('td', this);
start_id = $(nTds[0]).text() ;
},
update: function(event, ui) {
endPosition = ui.item.prevAll().length + 1;
var end_id = ui.item.context.children[0].innerHTML;
alert('Start Position: ' + (start_id+1) + ' End Position: ' + end_id);
}
// SERVER SIDE FUNCTIONS ..............
});
});
[/code]
for example start order column is 1 with engine is HELLO and stop order is 4 with engine is WORLD , i want to change HELLO order to 4 and change WORLD order to 1,
[code]
$(document).ready(function() {
$('#datatable-wrapper').append('');
$('#example').dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aaData": [
[ "1" , "HELLO", "----", "----", 0, "A" ],
[ "4" , "WORLD", "----", "----", 0, "A" ]
],
"aoColumns": [
{ "sTitle": "ORDER" },
{ "sTitle": "Engine" },
{ "sTitle": "Browser" },
{ "sTitle": "Platform" },
{ "sTitle": "Version", "sClass": "center" },
{
"sTitle": "Grade",
"sClass": "center",
"fnRender": function(obj) {
var sReturn = obj.aData[ obj.iDataColumn ];
if ( sReturn == "A" ) {
sReturn = "A";
}
return sReturn;
}
}
]
});
var startPosition;
var endPosition;
var start_id;
var end_id ;
$("#example tbody").sortable({
cursor: "move",
start:function(event, ui){
startPosition = ui.item.prevAll().length + 1;
var nTds = $('td', this);
start_id = $(nTds[0]).text() ;
},
update: function(event, ui) {
endPosition = ui.item.prevAll().length + 1;
var end_id = ui.item.context.children[0].innerHTML;
alert('Start Position: ' + (start_id+1) + ' End Position: ' + end_id);
}
// SERVER SIDE FUNCTIONS ..............
});
});
[/code]
This discussion has been closed.