BServerSide and multiple word search

BServerSide and multiple word search

vedranbevedranbe Posts: 9Questions: 0Answers: 0
edited October 2010 in General
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]

Replies

  • vedranbevedranbe Posts: 9Questions: 0Answers: 0
    ---------------------------
    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
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Sorry I think I'm missing what the issue is - it it state saving, or multiple word searching like the threat title says?

    Allan
  • vedranbevedranbe Posts: 9Questions: 0Answers: 0
    Actually I need both. At the moment, only state saving works. It doesn't work properly only when using BProccessing alone (Pagination doesn't work). Everything else is OK.

    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 ;)
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    First point - it's a lower case "b" for bPorcessing and bServerSide :-) (just incase...).

    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
  • vedranbevedranbe Posts: 9Questions: 0Answers: 0
    "First point - it's a lower case "b" for bPorcessing and bServerSide :-) (just incase...)." - this is OK in my code ;)

    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
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    The sEcho looks dodgy - it should never be 0 with server-side processing. It should be 1 or higher, incrementing by one for every draw. That might be the problem there. Just echo back the sEcho parameter sent to you (parsed as an int for security reasons!).

    Allan
  • vedranbevedranbe Posts: 9Questions: 0Answers: 0
    It was the code when I access server_processing.php directly.

    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.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I see. Can you post the JSON that is returned from the server when looking at the XHR through Firebug please? I don't see anything obvious for why it won't work. If you can give us a link that would be most useful.

    Allan
  • vedranbevedranbe Posts: 9Questions: 0Answers: 0
    edited October 2010
    This is part of Params:
    [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... ;)
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I'm afraid I don't see what the problem is? It seems to be working okay for me. I can filter, sort, page etc, and it's all stored in the state saving cookie, and restored on refresh...

    Allan
  • vedranbevedranbe Posts: 9Questions: 0Answers: 0
    The problem is when I type more than one word it gives no result. Everything else works fine now.

    I need to search for words from all columns.

    Vedran
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Oh I see - you are looking for multiple word filtering like DataTables when using client-side processing - sorry for hte confusion. There is a note in the PHP demo script which says:

    [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
  • vedranbevedranbe Posts: 9Questions: 0Answers: 0
    That's exactly what I need and I know about this note :) I just couldn't find a solution or an example.
  • JulanJulan Posts: 26Questions: 0Answers: 0
    This is really important, has anybody found a solution to this? I also need to use regex filtering for server-side processing but I haven't been able to make it work yet. =/
  • vedranbevedranbe Posts: 9Questions: 0Answers: 0
    Unfortunately I haven't :(
  • JulanJulan Posts: 26Questions: 0Answers: 0
    Hey vedranbe, thought you might like to see this : http://datatables.net/forums/comments.php?DiscussionID=3343&page=1#Item_6

    I figured you were signed up to replies here but not in the other thread. Hope that helps.

    :)
This discussion has been closed.