Select all with Server-side
Select all with Server-side
Sorry for my english.
Many thanks for such a good plugin, but I have a small problem :
I have 3 form and database > 200k rows
1. form -global search for filtering ( search by city, streets and other column) - html form
2. form - filtering table from request 1 form ( Here, users select objects for processing ) - datatables with multiple select and server-side data.
3. form - view or edit data from form 2. - html form
on form 2 -
I need to create a button - to select all rows for processing. this should be a button under the table
button to select rows on all pages, and add data to an array of "column1"
live preview http://85.236.175.190/pugachev/
The problem is that the separation takes place only on the first page - all the rest of the selection is not happening.
thanks in advance
Many thanks for such a good plugin, but I have a small problem :
I have 3 form and database > 200k rows
1. form -global search for filtering ( search by city, streets and other column) - html form
2. form - filtering table from request 1 form ( Here, users select objects for processing ) - datatables with multiple select and server-side data.
3. form - view or edit data from form 2. - html form
on form 2 -
I need to create a button - to select all rows for processing. this should be a button under the table
button to select rows on all pages, and add data to an array of "column1"
live preview http://85.236.175.190/pugachev/
The problem is that the separation takes place only on the first page - all the rest of the selection is not happening.
thanks in advance
This discussion has been closed.
Replies
What you need to do is something like in this example: http://datatables.net/release-datatables/examples/server_side/select_rows.html 0- keep track of which rows are selected (and introduce a new 'selected all' flag so rows can be selected when they are drawn.
Allan
HTML
[code]
column1
column2
column3
column4
column5
column6
column7
loading data from server
Next
[/code]
Javascript
[code]
var select_all;
var oTable;
var selected = new Array();
function select_all_fn ()
{
var nNodes = oTable.fnGetNodes( );
$(nNodes).each( function () {
$(this).addClass('row_selected');
});
}
function select_all_click() {
if (select_all!=2) {
select_all=2;
select_all_fn();
}
}
$(document).ready(function() {
$('#form').submit( function() {
if (select_all==2) {
$.post("/base/base.php?data=select",{VIBORNE1:selected,select_all:select_all},function(data) {
location.href='/base/index.php?menu=kartocka-3';
} );
}
else {
$.post("/base/base.php?data=select",{VIBORNE1:selected},function(data) {
location.href='/komitet/index.php?menu=kartocka-3';
} );
}
return false;
} );
oTable = $('#example').dataTable( {
"bServerSide": true,
"sAjaxSource": "/base/base.php?data=data",
"sDom": 'lrtip<"clear">',
"fnDrawCallback": function ( oSettings ) {
if (select_all==2 ) {
select_all_fn();
}
$('#example tbody tr').each( function () {
var iPos = oTable.fnGetPosition( this );
if (iPos!=null) {
var aData = oTable.fnGetData( iPos );
if (jQuery.inArray(aData[0], selected)!=-1)
$(this).addClass('row_selected');
}
$(this).click( function () {
var iPos = oTable.fnGetPosition( this );
var aData = oTable.fnGetData( iPos );
var iId = aData[0];
is_in_array = jQuery.inArray(iId, selected);
if (is_in_array==-1) {
selected[selected.length]=iId;
}
else {
selected = jQuery.grep(selected, function(value) {
return value != iId;
});
}
if ( $(this).hasClass('row_selected') ) {
$(this).removeClass('row_selected');
}
else {
$(this).addClass('row_selected');
}
});
});
},
});
} );
[/code]
PHP
[code]
switch ($_GET['data']){
case "select":
if ($_POST['select_all']=="2" ) {
$sQuery="SELECT * FROM tbl }
else {
if (isset($_POST['VIBORNE1'])) {
foreach ($_POST['VIBORNE1'] as $key => $value) {
$sWhere .= "$key = $value AND ";
}
$sWhere = substr_replace( $sWhere, "", -4 );
$sQuery="SELECT * FROM tbl".$sWhere;
[/code]
SQL queries are incorrect but the logic is clear request