BServerSide and multiple word search
BServerSide and multiple word search
Hi everyone,
I'm having a problem with multiple word search and server side processing. Couldn't find a solution anywhere so I am kindly asking anyone to help me :) If I use BProcessing only everything works fine except it doesn't save the state of pagination. That works with BServerSide but I need search more...
version: 1.7.3.
Here is my code:
[code]
$(document).ready(function() {
var oTable;
oTable = $('#table_content').dataTable( {
"fnDrawCallback": function() {
$('.license_status_yes').live('click', function(event){
event.preventDefault();
var parent = '';
$('a.license_status_yes').click(function(e) {
e.preventDefault();
parent = $(this).parent("td").parent("tr");
$('#license_status_yes').dialog('open');
return false;
});
$('#license_status_yes').dialog({
autoOpen: false,
width: 300,
buttons: {
"Ok": function() {
$.ajax({
type: 'get',
url: 'components/com_joomsa/files/change.php',
data: 'ajax=1&license_status=' + $('div.div_yes').attr('name') + ',YES',
beforeSend: function() {
parent.animate(300);
parent.css('background-color', '#82d892');
},
success: function() {
location.reload();
}
});
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
});
$('.license_status_no').live('click', function(event){
event.preventDefault();
var parent = '';
$('a.license_status_no').click(function(e) {
e.preventDefault();
parent = $(this).parent("td").parent("tr");
$('#license_status_no').dialog('open');
return false;
});
$('#license_status_no').dialog({
autoOpen: false,
width: 300,
buttons: {
"Ok": function() {
$.ajax({
type: 'get',
url: 'components/com_joomsa/files/change.php',
data: 'ajax=1&license_status=' + $('div.div_no').attr('name') + ',NO',
beforeSend: function() {
parent.animate(300);
parent.css('background-color', '#82d892');
},
success: function() {
location.reload();
}
});
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
});
$('.license_status_kill').live('click', function(event){
event.preventDefault();
var parent = '';
$('a.license_status_kill').click(function(e) {
e.preventDefault();
parent = $(this).parent("td").parent("tr");
$('#license_status_kill').dialog('open');
return false;
});
$('#license_status_kill').dialog({
autoOpen: false,
width: 300,
buttons: {
"Ok": function() {
$.ajax({
type: 'get',
url: 'components/com_joomsa/files/change.php',
data: 'ajax=1&license_status=' + $('div.div_kill').attr('name') + ',KILL',
beforeSend: function() {
parent.animate(300);
parent.css('background-color', '#82d892');
},
success: function() {
location.reload();
}
});
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
});
},
"bJQueryUI": true,
"bServerSide": true,
"bProcessing": true,
"sAjaxSource": "server_processing.php",
"bStateSave": true,
"iDisplayLength": 10,
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"bInfo": true,
"sPaginationType": "full_numbers",
"sDom": '<"top"flip>rt<"bottom"fip<"clear">',
"aaSorting": [[ 1, "asc" ]],
"aoColumns": [
{ "bSortable": false, "sClass": "checkbox" },
null,
null,
null,
null,
null,
{ "bSortable": false, "sType": "html" }
],
"oLanguage": {
"sSearch": "Search all columns:"
}
} );
} );
[/code]
I'm having a problem with multiple word search and server side processing. Couldn't find a solution anywhere so I am kindly asking anyone to help me :) If I use BProcessing only everything works fine except it doesn't save the state of pagination. That works with BServerSide but I need search more...
version: 1.7.3.
Here is my code:
[code]
$(document).ready(function() {
var oTable;
oTable = $('#table_content').dataTable( {
"fnDrawCallback": function() {
$('.license_status_yes').live('click', function(event){
event.preventDefault();
var parent = '';
$('a.license_status_yes').click(function(e) {
e.preventDefault();
parent = $(this).parent("td").parent("tr");
$('#license_status_yes').dialog('open');
return false;
});
$('#license_status_yes').dialog({
autoOpen: false,
width: 300,
buttons: {
"Ok": function() {
$.ajax({
type: 'get',
url: 'components/com_joomsa/files/change.php',
data: 'ajax=1&license_status=' + $('div.div_yes').attr('name') + ',YES',
beforeSend: function() {
parent.animate(300);
parent.css('background-color', '#82d892');
},
success: function() {
location.reload();
}
});
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
});
$('.license_status_no').live('click', function(event){
event.preventDefault();
var parent = '';
$('a.license_status_no').click(function(e) {
e.preventDefault();
parent = $(this).parent("td").parent("tr");
$('#license_status_no').dialog('open');
return false;
});
$('#license_status_no').dialog({
autoOpen: false,
width: 300,
buttons: {
"Ok": function() {
$.ajax({
type: 'get',
url: 'components/com_joomsa/files/change.php',
data: 'ajax=1&license_status=' + $('div.div_no').attr('name') + ',NO',
beforeSend: function() {
parent.animate(300);
parent.css('background-color', '#82d892');
},
success: function() {
location.reload();
}
});
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
});
$('.license_status_kill').live('click', function(event){
event.preventDefault();
var parent = '';
$('a.license_status_kill').click(function(e) {
e.preventDefault();
parent = $(this).parent("td").parent("tr");
$('#license_status_kill').dialog('open');
return false;
});
$('#license_status_kill').dialog({
autoOpen: false,
width: 300,
buttons: {
"Ok": function() {
$.ajax({
type: 'get',
url: 'components/com_joomsa/files/change.php',
data: 'ajax=1&license_status=' + $('div.div_kill').attr('name') + ',KILL',
beforeSend: function() {
parent.animate(300);
parent.css('background-color', '#82d892');
},
success: function() {
location.reload();
}
});
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
});
},
"bJQueryUI": true,
"bServerSide": true,
"bProcessing": true,
"sAjaxSource": "server_processing.php",
"bStateSave": true,
"iDisplayLength": 10,
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"bInfo": true,
"sPaginationType": "full_numbers",
"sDom": '<"top"flip>rt<"bottom"fip<"clear">',
"aaSorting": [[ 1, "asc" ]],
"aoColumns": [
{ "bSortable": false, "sClass": "checkbox" },
null,
null,
null,
null,
null,
{ "bSortable": false, "sType": "html" }
],
"oLanguage": {
"sSearch": "Search all columns:"
}
} );
} );
[/code]
This discussion has been closed.
Replies
server_processing.php
This code was not changed... Everything I've tried was without any result so it's still in initial stage.
[code]
/* Paging */
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}
/* Ordering */
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i
Allan
I need BServerSide to work with multiple words. I wouldn't use server side but it seems it's gonna be something like 20-30K of records:) There was no solution on this forum that helped me with multiple word search:(
I hope you could help me Allan:)
Thanks ;)
So one issue at a time - with server-side processing, what is your initialisation code? And what JSON return are you getting from the server?
Allan
This is the output. Everything is valid. I've checked it with jsonlint.com.
[code]{"sEcho": 0, "iTotalRecords": 836, "iTotalDisplayRecords": 836, "aaData": [ ["","Multiconsult A/S","CQToolsS","MCB-052","KILL","China"," "],["","CAD-Q","CQToolsC3D1","kurs2006","YES","Macedonia, the Former Yugoslav Republic of"," "]...[/code]
Mu initalisation code is already posted if that's what you mean.
Vedran
Allan
This is from Firebug when I run the site:
[code]bRegex false
bRegex_0 false
bRegex_1 false
bRegex_2 false
bRegex_3 false
bRegex_4 false
bRegex_5 false
bRegex_6 false
bSearchable_0 true
bSearchable_1 true
bSearchable_2 true
bSearchable_3 true
bSearchable_4 true
bSearchable_5 true
bSearchable_6 true
bSortable_0 false
bSortable_1 true
bSortable_2 true
bSortable_3 true
bSortable_4 true
bSortable_5 true
bSortable_6 false
iColumns 7
iDisplayLength 10
iDisplayStart 0
iSortCol_0 1
iSortingCols 1
sColumns
sEcho 11
sSearch
sSearch_0
sSearch_1
sSearch_2
sSearch_3
sSearch_4
sSearch_5
sSearch_6
sSortDir_0 asc[/code]
sEcho is OK in this case.
Allan
[code]
sSearch 65 yes
sSearch_0
sSearch_1
sSearch_2
sSearch_3
sSearch_4
sSearch_5
sSearch_6
sSortDir_0 asc
[/code]
This is response:
[code]
{"sEcho": 4, "iTotalRecords": 836, "iTotalDisplayRecords": 0, "aaData": [] }
[/code]
This is the test site ;)
http://www.sayber.com/projects/cadqlicense/
Everything I need is at homepage.
I thought I could send you a PM with this but... ;)
Allan
I need to search for words from all columns.
Vedran
[code]
/*
* Filtering
* NOTE this does not match the built-in DataTables filtering which does it
* word by word on any field. It's possible to do here, but concerned about efficiency
* on very large tables, and MySQL's regex functionality is very limited
*/
[/code]
So the demo script doesn't do that across fields. It would require a modification of the script. The solution would be to concatenate all fields together and then do something like the regex smart filtering that DataTables applies client-side - but I'm not sure that MySQL can use a reverse lookup...
Allan
I figured you were signed up to replies here but not in the other thread. Hope that helps.
:)