Browse Source

Improve pivot table sorting

Add the cursor (asc, desc) only on the total columns.
pull/390/head
dufresnedavid 8 years ago
parent
commit
9ad830d54c
  1. 22
      web_graph_sort/static/src/js/web_graph_sort.js

22
web_graph_sort/static/src/js/web_graph_sort.js

@ -20,9 +20,16 @@ openerp.web_graph_sort = function(instance) {
draw_measure_row: function (measure_row) {
var $row = $('<tr>').append('<th>');
var self = this;
var measures = _.unique(_.map(measure_row, function(cell){return cell.text;}));
var measure_index = _.indexBy(self.measure_list, 'string');
var first_total_index = measure_row.length - measures.length;
var column_index = 0;
_.each(measure_row, function (cell) {
_.each(self.measure_list,function(item){
if(item.string === cell.text) {
var item = measure_index[cell.text];
if(item){
var data_id;
if (
self.pivot.sort !== null &&
@ -44,12 +51,17 @@ openerp.web_graph_sort = function(instance) {
if (cell.is_bold) {
$cell.css('font-weight', 'bold');
}
if (self.pivot.sort !== null && self.pivot.sort[0].indexOf(item.field) >= 0) {
if (
column_index >= first_total_index &&
self.pivot.sort !== null &&
self.pivot.sort[0].indexOf(item.field) >= 0
) {
$cell.addClass((self.pivot.sort[0].indexOf('-') === -1) ? "sortdown": "sortup");
}
$row.append($cell);
column_index += 1;
}
});
$row.append($cell);
});
this.$thead.append($row);
},

Loading…
Cancel
Save