mitchell852 commented on a change in pull request #3680: TP: adds the ability
to rearrange table columns as well as toggle column visibility/searchability
URL: https://github.com/apache/trafficcontrol/pull/3680#discussion_r295903316
##########
File path:
traffic_portal/app/src/common/modules/table/types/TableTypesController.js
##########
@@ -33,15 +37,34 @@ var TableTypesController = function(types, $scope, $state,
locationUtils) {
$state.reload(); // reloads all the resolves for the view
};
+ $scope.toggleVisibility = function(colName) {
+ const col = table.column(colName + ':name');
+ col.visible(!col.visible());
+ table.rows().invalidate().draw();
+ };
+
angular.element(document).ready(function () {
- $('#typesTable').dataTable({
- "aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
- "iDisplayLength": 25,
- "aaSorting": []
- });
+ table = $('#typesTable').DataTable({
+ "lengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
+ "iDisplayLength": 25,
+ "aaSorting": [],
+ "columns": [
+ { "name": "name", "visible": true, "searchable": true },
+ { "name": "description", "visible": true, "searchable":
true },
+ { "name": "lastUpdated", "visible": false, "searchable":
false },
+ { "name": "useInTable", "visible": true, "searchable":
true }
+ ],
+ "colReorder": {
+ realtime: false
+ },
+ "initComplete": function(settings, json) {
+ // need to create the show/hide column checkboxes and bind
to the current visibility
+ $scope.columns =
JSON.parse(localStorage.getItem('DataTables_typesTable_/')).columns;
Review comment:
actually, failure to parse will just result in an empty dropdown


and it won't affect the rest of the UI, but i like the idea of providing
some sort of info as to the problem.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services