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_r295495468
##########
File path:
traffic_portal/app/src/common/modules/table/types/TableTypesController.js
##########
@@ -33,15 +37,43 @@ 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());
+ // hack alert: there is no api to set searchable on a column but if
the column is visible, then it's searchable
+ table.context[0].aoColumns[col.index()].bSearchable = col.visible();
+ // redraw so the column's searchable value is taken into account
+ 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 bind the show/hide column checkboxes to the
saved visibility
+ $scope.columns =
JSON.parse($window.localStorage['DataTables_typesTable_/'])['columns'];
Review comment:
ok, i'll see what i can clean up here. thanks
----------------------------------------------------------------
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