[IMP] add rendering of basic table in pivottable widget (addon web_graph)

bzr revid: ged@openerp.com-20131112135344-fi7mwyd49bqnbg69
This commit is contained in:
Gery Debongnie 2013-11-12 14:53:44 +01:00
parent 4d7150fc58
commit 298a7012bf
3 changed files with 33 additions and 4 deletions

View File

@ -0,0 +1,12 @@
.graph_main_content td {
border: 1px solid black;
padding: 0.5rem;
text-align: right;
}
td.graph_border {
background-color: rgb(227, 227, 227);
text-align: left;
}

View File

@ -10,6 +10,7 @@ openerp.web_graph = function (instance) {
var _lt = instance.web._lt;
var _t = instance.web._t;
var QWeb = instance.web.qweb;
instance.web.views.add('graph', 'instance.web_graph.GraphView');
@ -94,6 +95,7 @@ var BasicDataView = instance.web.Widget.extend({
this.fields = fields;
this.groupby = groupby;
this.measure = measure;
this.measure_label = measure ? fields[measure].string : 'Quantity';
},
show: function () {
@ -113,7 +115,23 @@ var PivotTable = BasicDataView.extend({
template: 'pivot_table',
draw: function () {
console.log('data',this.data);
var self = this;
console.log("data",this.data);
var rows = '<tr><td class="graph_border">' +
this.fields[this.groupby[0]].string +
'</td><td class="graph_border">' +
this.measure_label +
'</td></tr>';
_.each(this.data, function (datapt) {
rows += '<tr><td class="graph_border">' +
datapt.attributes.value[1] +
'</td><td>' +
datapt.attributes.aggregates[self.measure]+
'</td></tr>';
});
this.$el.append(rows);
},
});
@ -181,10 +199,9 @@ var ChartView = BasicDataView.extend({
},
render_line_chart: function () {
var measure_label = (this.measure) ? this.measure : 'Quantity';
var formatted_data = [{
key: measure_label,
key: this.measure_label,
values: _.map(this.data, this.format_data.bind(this))
}];

View File

@ -19,7 +19,7 @@
</t>
<t t-name="pivot_table">
<div>Hello Pivot</div>
<table></table>
</t>
<t t-name="chart_view">