diff --git a/horizon/static/horizon/js/horizon.tables.js b/horizon/static/horizon/js/horizon.tables.js index 1ae2f4c8f..46e8ca08e 100644 --- a/horizon/static/horizon/js/horizon.tables.js +++ b/horizon/static/horizon/js/horizon.tables.js @@ -232,6 +232,13 @@ horizon.datatables.remove_no_results_row = function (table) { table.find("tr.empty").remove(); }; +/* + * Fixes the striping of the table after filtering results. +**/ +horizon.datatables.fix_row_striping = function (table) { + table.trigger('applyWidgetId', ['zebra']); +}; + horizon.datatables.set_table_sorting = function (parent) { // Function to initialize the tablesorter plugin strictly on sortable columns. $(parent).find("table.datatable").each(function () { @@ -302,6 +309,7 @@ horizon.datatables.set_table_query_filter = function (parent) { table = $(table_selector); horizon.datatables.update_footer_count(table); horizon.datatables.add_no_results_row(table); + horizon.datatables.fix_row_striping(table); }, prepareQuery: function (val) { return new RegExp(val, "i"); @@ -325,6 +333,7 @@ horizon.datatables.set_table_fixed_filter = function (parent) { table.find('tbody tr.category-' + category).show(); horizon.datatables.update_footer_count(table); horizon.datatables.add_no_results_row(table); + horizon.datatables.fix_row_striping(table); }); $(elm).find('div.table_filter button').each(function (i, button) { // Select the first non-empty category diff --git a/openstack_dashboard/static/dashboard/less/horizon.less b/openstack_dashboard/static/dashboard/less/horizon.less index c0f58466b..ddb33e52c 100644 --- a/openstack_dashboard/static/dashboard/less/horizon.less +++ b/openstack_dashboard/static/dashboard/less/horizon.less @@ -636,6 +636,25 @@ table form { display: none; } +/* + * Bootstrap styles table backgrounds using nth-child(2n+1), which is + * oblivious to hidden elements. The styles below allow us to override + * the bootstrap style when neccessary by setting the odd/even classes. + */ +.table-striped.datatable tbody { + tr.odd td { + background-color: #f9f9f9; + } + tr.even td { + background-color: inherit; + } + tr.odd:hover td, + tr.even:hover td, + tr:hover th { + background-color: #f5f5f5; + } +} + .table-striped tbody tr.status_unknown:nth-child(odd) td { background-color: #ffffb5; }