Point to a different server side file after table is initialized?

Point to a different server side file after table is initialized?

tihg7947tihg7947 Posts: 9Questions: 0Answers: 0
edited October 2013 in General
Is there a way to initialize a table using one sAjaxSource and then after the table is initialized, point the table to a different sAjaxSource?

I have a general search box on every page on my site where the user can search and be sent to a table (one server-side file). Once at the table, I want the user to search using individual columns (another server-side file). I have both files working correctly, just not switching because I'm not sure how?

I hope I was clear enough.

Replies

  • tihg7947tihg7947 Posts: 9Questions: 0Answers: 0
    edited October 2013
    EDIT:
    I found a workaround, or perhaps the correct way :)
    I would still love to hear if this switching between server-side files after an initial Draw is possible but I think there is a more practical, efficient approach. I just used aoData.push to send the value from the global search to the same sAjaxSource as the individual column filtering and then just used an IF ... THEN statement inside the server-side file.

    I am programming in asp classic so this references the setup given here http://www.datatables.net/development/server-side/asp_classic

    So in my $("#Table").dataTable :

    [code]
    $("#Table").dataTable({
    bProcessing: true,
    bServerSide: true,
    sAjaxSource: "ServerSide.asp",
    bLengthChange: false,
    sDom: '<"OpenTitle">frtip',
    iDisplayLength: 10,
    aoColumns: [null, null, null, null, null, null, null],
    oLanguage: {"sSearch": "Search Open Work Order NOTES:" },
    oSearch: {"sSearch": ""},
    aaSorting: [[ 4, "asc" ]],
    fnServerParams: function ( aoData ) {
    aoData.push( { "name" : "SearchQuery", "value" : "<%=Value %>" } );
    },
    bSortCellsTop: true,
    bFiltered: true
    }),
    [/code]

    And in my serverside file:

    [code]
    WorkOrderSearch = Request.QueryString("SearchQuery")

    'Building the general search query
    GlobalSearch = empty
    IF SearchQuery = "" OR IsNull(SearchQuery) = True THEN
    GlobalSearch = ""
    ELSE
    GlobalSearch = "AND ( X LIKE '%" & GlobalSearch & "%' "_
    & "OR Y LIKE '%" & GlobalSearch & "%' "_
    & "OR Z LIKE '%" & GlobalSearch & "%' )"
    END IF
    [/code]

    That way I can append it to the strWhere query built later on. This way I can allow for general searching as well as individual column filtering. I hope this helps anyone else.
This discussion has been closed.