Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2918 Zobrazení

I want to override "_render: function ()" function from pivot_renderer.js file in web but not working in custom module. Here is the code i am implementing in my custom module:-

odoo.define('MY_CUSTOM_MODULE_NAME.renderer', function (require) {
"use strict";
var PivotRenderer = require('web.PivotRenderer');
var field_utils = require('web.field_utils');
var core = require('web.core');
var _t = core._t;
PivotRenderer.include({
init: function(parent, state, params) {
       this._super.apply(this, arguments);
    },
    _render: function () {
       if (!this._hasContent()) {
        // display the nocontent helper
        this.replaceElement(QWeb.render('PivotView.nodata'));
        return this._super.apply(this, arguments);
    }
    if (!this.$el.is('table')) {
        // coming from the no content helper, so the root element has to be
        // re-rendered before rendering and appending its content
        this.renderElement();
    }
    var $fragment = $(document.createDocumentFragment());
    var $table = $('').appendTo($fragment);
    var $thead = $('').appendTo($table).addClass("CLASS_NAME");
    var $tbody = $('').appendTo($table);
    var nbr_measures = this.state.measures.length;
    var nbrCols = (this.state.mainColWidth === 1) ?
        nbr_measures :
        (this.state.mainColWidth + 1) * nbr_measures;
    for (var i=0; i < nbrCols + 1; i++) {
        $table.prepend($(''));
    }
    this._renderHeaders($thead, this.state.headers);
    this._renderRows($tbody, this.state.rows);
    // todo: make sure the next line does something
    $table.find('.o_pivot_header_cell_opened,.o_pivot_header_cell_closed').tooltip();
    this.$el.html($table.contents());
    return this._super.apply(this, arguments);
},
});
});

In the above, i want to add a class in the header for calling my custom css "var $thead = $('').appendTo($table).addClass("CLASS_NAME");" with this syntax but it is not reflecting in my custom module. Although, for testing, I have implemented same class in default web module and it is working fine. The issue is in custom module.

So how to solve this issue? Is there any other way for calling class or i am doing it in a wrong way?


Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
lis 22
3133
2
srp 22
7472
1
led 25
9142
1
zář 21
6489
1
bře 21
5203