<TABLE id='documents'> <THEAD> <tr> <th>Event ID</th> <th>Date</th> <th>Subject</th> <th>Result</th> </tr> </THEAD> <TBODY> <tr> <td></td> <td></td> <td></td> <td></td> </tr> </TBODY> </TABLE>
var oTable = $('#documents').dataTable({
"aoColumns": [
{ "sTitle": "EventID", "bVisible": false },
{ "sTitle": "Date", "sWidth": "110px", "bSortable": true },
{ "sTitle": "Subject", "sWidth": "270px", "bSortable": true },
{ "sTitle": "Result", "sWidth": "100px", "bSortable": true }],
"bRetrieve": true,
"bProcessing": true,
"bDestroy": true,
"bPaginate": false,
"bAutoWidth": false,
"bFilter": false,
"bInfo": false,
"aaSorting": [[1, 'desc']],
"bJQueryUI": false
});
function DocumentsTable(fromDate, toDate) {
if (fromDate !== 0) {
// if we are working with dates, make them date data type instead of strings:
var documentFrom = new Date(fromDate);
var documentTo = new Date(toDate);
}
else {
// put the vanilla zeroes into the documentFrom, documentTo variables this routine uses:
var documentFrom = 0;
var documentTo = 0;
};
// Initialize the request object:
var DocumentInfo = new XMLCclRequest();
// When our request object has changed:
DocumentInfo.onreadystatechange = function () {
if (DocumentInfo.readyState == 4 && DocumentInfo.status == 200) {
// Convert returned string to JSON object (eval):
var msgDoc = DocumentInfo.responseText;
if (msgDoc !== undefined && msgDoc !== null) {
var jsonDoc = eval("(" + msgDoc + ")");
}
if (jsonDoc && jsonDoc.DATAREC.LIST) {
var oTable = $("#documents").dataTable({
"aoColumns": [
{ "sTitle": "EventID", "bVisible": false},
{ "sTitle": "Date", "sWidth": "110px", "bSortable": true},
{ "sTitle": "Subject (click any column name to sort)", "sWidth": "270px", "bSortable": true},
{ "sTitle": "Result", "sWidth": "100px", "bSortable": true}
],
"bProcessing": true,
"bDestroy": true,
"bPaginate": false,
"bAutoWidth": false,
"bFilter": false,
"bInfo": false,
"aaSorting": [[1, 'desc']],
"bJQueryUI": false
}); // end var oTable definition
// append each row to the oTable datatable:
for (var i = 0; i < jsonDoc.DATAREC.LIST.length; i++) {
oTable.fnAddData([
//event_ID is not visible to the user:
jsonDoc.DATAREC.LIST[i].EVENT_ID,
jsonDoc.DATAREC.LIST[i].EVENT_DT,
jsonDoc.DATAREC.LIST[i].EVENT_TITLE_TEXT,
jsonDoc.DATAREC.LIST[i].EVENT_RESULT
]);
} // end for loop
} //end if (jsonDoc &&...
else
// We don't have any data to work with:
{ $('#documents').html('No Documents Found')}
}; //end if (DocumentInfo.readyState === 4 &&...
} //end DocumentInfo.onreadystatechange
// Call the ccl progam and send the parameter string:
DocumentInfo.open("GET", "MPAGE_DOC");
if (documentFrom === 0) {
// the initial trip through, we pass in zeroes instead of dates:
DocumentInfo.send("^MINE^, value($VIS_Encntrid$), value($PAT_Personid$), ^0^,^0^");
}
else
{
// user has selected dates so format them for the CCL request:
DocumentInfo.send("^MINE^, value($VIS_Encntrid$), value($PAT_Personid$), ^" + documentFrom.format('mmddyyyy') + "^,^" + documentTo.format('mmddyyyy') + "^");
};
return;
} //end DocumentsTable ()
/*
* Register a new feature with DataTables
*/
if ( typeof $.fn.dataTable == "function" &&
typeof $.fn.dataTableExt.fnVersionCheck == "function" &&
$.fn.dataTableExt.fnVersionCheck('1.7.4') )
{
$.fn.dataTableExt.oApi.fnProcessingIndicator = function ( oSettings, onoff )
{
if( typeof(onoff) == 'undefined' )
{
onoff=true;
}
this.oApi._fnProcessingDisplay( oSettings, onoff );
}
$.fn.dataTableExt.oJUIClasses.sProcessing="dataTables_processing ui-state-highlight";
}
else
{
alert( "Warning: SearchForm requires DataTables 1.7.4 or greater - www.datatables.net/download");
}
function processData(data)
{
//clear the table again in the case of a double submit
datatable.fnClearTable();
//add data to table
datatable.fnAddData(data);
//turn off processing indicator
datatable.fnProcessingIndicator(false);
}
// pre-submit callback
function preRequest(formData, jqForm, options) {
//turn on procesing indicator
datatable.fnProcessingIndicator(true);
//clear table
datatable.fnClearTable();
return true;
}
if (oTable != undefined) {
oTable.fnClearTable();
};
var oTable = $('#tableID').dataTable();
oTable.fnDestroy();
//I put in new values 'newList' on the body
$('#tableID tbody').html(newList);
//I reinitialize the datatable
$('#tableID').dataTable({"oLanguage": { "sSearch": 'Search Contacts:' }});
It looks like you're new here. If you want to get involved, click one of these buttons!
Get useful and friendly help straight from the source.