Pass a search filter via URL parameter
Pass a search filter via URL parameter
I already have a datatable up and running which shows open support tickets. On the header of all the pages I have a count of overdue tickets. I want that count to be a link, so when they click on it, it takes them to the datatables page and filters for overdue. My thought was making the link datatable.cfm/?sSearch_6=overdue
I am struggling to figure out how to pull the URL parameter and perform the search on the table. I also need it to operate normally if no parameter exists.
Thanks!
I am struggling to figure out how to pull the URL parameter and perform the search on the table. I also need it to operate normally if no parameter exists.
Thanks!
This discussion has been closed.
Replies
Allan
[code]
$(document).ready(function() {
var oTable = $('#example').dataTable({
"iDisplayLength":25,
"bAutoWidth":false,
"bJQueryUI": true, /* Enables ThemeRoller */
"sPaginationType": "full_numbers", /* Pagination Display */
"bProcessing": true, /* Show processing overlay */
"bServerSide": true, /* Use serverside processing */
"sAjaxSource": "/prism/includes/grids/tickets_handler.cfm", /* Serverside logic */
"aaSorting": [[8, "desc"],[ 3, "asc" ],[ 9, "asc" ]], /* Primary sorting (column 1 ascending) */
"bStateSave": true, /* Save the view state*/
"aoColumns": [
/*0 ID */ { "bSearchable": false, "bVisible": false }, /* Disables the visibility of the ID field */
/*1 Sub Dept */ { "bSearchable": true, "bVisible": false }, /* Disables the visibility of the ID field */
/*2 Age */ null,
/*3 Priority */ null,
/*4 System */ null,
/*5 Subject # */ null,
/*6 Status */ null,
/*7 Due # */ null,
/*8 ticket_assigned_status*/ { "bSearchable": false, "bVisible": false },/* Disables the visibility of the ID field */
/*9 create_timestamp */ { "bSearchable": false, "bVisible": false }, /* Disables the visibility of the ID field */
/*10 datatables_cell_color_code */ { "bSearchable": false, "bVisible": false } /* SQL handles logic of what the color code should be...makes Javascript logic simple */
],
"aoSearchCols": [
/*0 ID */ null,
/*1 Sub Dept */ null,
/*2 Age */ null,
/*3 Priority */ null,
/*4 System */ null,
/*5 Subject # */ null,
/*6 Status */ { "sSearch": "Assigned" },
/*7 Due # */ null,
/*8 ticket_assigned_status*/ null,
/*9 create_timestamp */ null,
/*10 datatables_cell_color_code */ null
],
//"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
// /* Replace 1 or 0 with Yes or No */
// if ( aData[4] == "1" )
// {
// $('td:eq(3)', nRow).html('Yes' );
// }
// else if ( aData[4] == "0" )
// {
// $('td:eq(3)', nRow).html('No');
// }
// return nRow;
//},
// CHANGE ROW TO GREEN IF STATUS IS SUBMITTED
"fnRowCallback": function( nRow, aaData, iDisplayIndex, iDisplayIndexFull ) {
if ( aaData[6] == "Submitted" )
{
// greencell IS THE CSS CLASS WITH THE CORRECT background-color
nRow.className = "greencell" + nRow.className
}
//return nRow;
else if (aaData[10] == "1")
{
//due date is overdue...color cell red
//nRow.className = "redcell" + nRow.className
var cellorder = "redcell" + nRow.className
$('td:eq(5)', nRow).toggleClass(cellorder);
}
return nRow;
},
fnDrawCallback: function() {
$('td').bind('mouseenter', function () { $(this).parent().children().each(function(){$(this).addClass('datatablerowhighlight');}); });
$('td').bind('mouseleave', function () { $(this).parent().children().each(function(){$(this).removeClass('datatablerowhighlight');}); });
clickRowHandler();
}
}); /* End datatable*/
[/code]
Allan
Also is there a way to have it so that the word would show in the Search field?