Ingoring the cookie or part of the cookie but only sometimes

Ingoring the cookie or part of the cookie but only sometimes

ErikSErikS Posts: 16Questions: 0Answers: 0
edited June 2012 in General
I would like to use the cookie most of the time, but sometimes not all of it.
I want to keep the values (sort, sort dir, rows per page, etc) most of the time, but I use the page with different layouts for different departments.

The first time I open the page for a given dept I want to ignore part of the cookie and default it to use defined values for that dept. In specific, the sort column. Then if they sort it by another column, i want to save and use that. If they then open the page for another dept, I want to ignore the saved values and use the defaults for that dept. I am identifying the dept using a session variable.

JSP
My question is, how do I tell the page to use cookies vs not use cookies vs use some of the values in the cookies?
<%=xxx%> is a jsp variable substitution. The following code is functioning well. I'd just like to add this one piece.
This is with DT version 1.7.6 - wondering if there are issues with upgrading.
[code] jQuery(document).ready( function () {

var oTable = jQuery('#assignment_table').dataTable({
"bProcessing": true,
"bStateSave": true,
"oLanguage": {
"sZeroRecords": "No results"
},
"fnDrawCallback": function ( oSettings ) {
/* Need to redo the counters if filtered or sorted */
if ( oSettings.bSorted || oSettings.bFiltered )
{
for ( var i=0, iLen=oSettings.aiDisplay.length ; i,
"iDisplayLength": <%=itemsPerPage%>,
"sDom": 'iplrtp<"clear">',
"sPaginationType": "full_numbers",
"aaSorting": [[ <%=sortColumn%>, "<%=sortDirection%>" ]],
"aoColumnDefs": [{
"bSortable": false, "aTargets": [0,1,2,3,4]
}],
"fnServerData": function (sSource, aoData, fnCallback) {
aoData.push({"name": "layout", "value": "<%=plLayout%>" });
aoData.push({"name": "status", "value": "<%=plStatus%>" });
aoData.push({"name": "cabinet", "value": "<%=plCabinet%>" });
aoData.push({"name": "upload", "value": "<%=plUpload%>" });
aoData.push({"name": "analyst", "value": "<%=plAnalyst%>" });
aoData.push({"name": "work", "value": "<%=plWork%>" });
aoData.push({"name": "column", "value": "<%=plColumn%>" });
aoData.push({"name": "operator", "value": "<%=plOperator%>" });
aoData.push({"name": "criteria", "value": "<%=plCriteria%>" });
aoData.push({"name": "includeAll", "value": "<%=plInclude%>" });
aoData.push({"name": "isAnalyst", "value": "<%=isAnalyst%>" });
aoData.push({"name": "userId", "value": "<%=userIdi%>" });
aoData.push({"name": "userDeptId", "value": "<%=userDeptIdi%>" });

jQuery.ajax({
"dataType": "json",
"type": "POST",
"url": sSource,
"data": aoData,
error: function (jqXHR, textStatus, errorThrown) {
ajaxFailedFunctionToCall = null
//jQuery("#assignment_table_processing").css({visibility: "hidden"});;
alert(jqXHR.status+','+textStatus+','+errorThrown);
},
success: function(data) {
if(data.exportLocation != undefined) {
window.location = data.exportLocation;
}
fnCallback(data);
}
})
}
});
new FixedHeader( oTable, { "zTop": "10" });
// these oSettings lines prevent the initial ajax call, but allow rest of calls to user ajax.
oSettings = oTable.fnSettings();
oSettings.oFeatures.bServerSide = <%=callDbUsingAjax%>;
oSettings.sAjaxSource = "/admin/ajax.jsp?action=assignListSort";
});
[/code]

Replies

  • ErikSErikS Posts: 16Questions: 0Answers: 0
    Let me try to clarify. Department (DEPT) is the variable. current is this load of the page, previous is the prior load of the page, which I have in a session attribute.

    If (current DEPT == previous DEPT) {
    use the cookie
    } else {
    sort using a default value for that DEPT
    }

    How do I do this?
This discussion has been closed.