Skip to content

Instantly share code, notes, and snippets.

@mwollenweber
Created October 12, 2014 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mwollenweber/c9f6a65d0cc346a8ebc5 to your computer and use it in GitHub Desktop.
Save mwollenweber/c9f6a65d0cc346a8ebc5 to your computer and use it in GitHub Desktop.
function addNetIDButtons(){
var rows = $('#emailRetentionTable').dataTable().fnGetNodes();
//var rows = oTable.fnGetNodes();
alert(rows.length);
for(var i=0; i<=rows.length; i++){
//get the cell contents of the email row
var data = rows[0].cells[0].innerHTML;
var pre = "<div class=\"btn-group\"><button type=\"button\" class=\"btn btn-default dropdown-toggle\" data-toggle=\"dropdown\"> ";
var post = " </button><ul class=\"dropdown-menu\" role=\"menu\"><li><a href=\"#\">Disable NetID</a></li><li><a href=\"#\">Enable NetID</a></li><li><a href=\"#\">View Audits</a></li><li><a href=\"#\">Queue Audit</a></li></ul></div></td> ";
rows[0].cells[0].innerHTML = pre + data + post;
} //end of for each row
}//end addNetIDButton
$(document).ready(function () {
$('.retainSearch').on('submit', function () {
//get search parameters
var searchField = $('#searchField').val();
var searchValue = $('#searchValue').val();
//destroy the table if it already exists
//if table exists can't change the data source
var oTable = $('#emailRetentionTable').dataTable();
if(oTable != null)
oTable.fnDestroy();
//load the table
//loadRetentionTable(searchField, searchValue);
$('#emailRetentionTable').dataTable( {
// "order": [[1, 'asc']]
"fnInitComplete": addNetIDButtons(),
"info": false,
"dom": '<"container" <"row" <"top" <"span2 pull-left"<"toolbar">> <"span4 pull-right" f>>>>rt<"bottom"><"span2 pull-right" p><"clear">',
"search": true,
"ajax": "/getEmailAccounts?searchField=" + searchField + "&searchValue=" + searchValue,
"columns": [
{ "data": "email" },
{ "data": "fName" },
{ "data": "lName" },
{ "data": "isMailboxSetup"},
{ "data": "isSuspended"},
{ "data": "lastLogin"}]
});
$('#searchResults').removeClass("hidden").addClass("show");
return false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment