Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
4447 Widoki

I want to create a special custom view for kanban. This view has to have special View Manager too.
In my_module_view.xml file I have menuitem and action definition. Action has context: 

<field name="context">{'special_view': True}</field>

Into my_module.js file I want to change template of instance.web.ViewManager only when context has 'special_view' true.

init: function (parent, dataset, view_id, options) {
    if (this.dataset.context.special_view) {
    	this.template = "MyViewManager";
    }
    this._super(parent, dataset, view_id, options);
 },
Unfortunately, this.dataset is null and I get this exception: Uncaught TypeError: Cannot read property 'context' of undefined.

Is there another way to change this template according to special_view value of context?

Thank you.

Awatar
Odrzuć
Autor Najlepsza odpowiedź

Because I've found a solution myself, I want to answer my own question, in case someone will have the same problem.

The code was right, but I was customizing the wrong Class.

SOLUTION:


instance.web.ViewManagerAction.include({
    init: function (parent, dataset, view_id, options) { this._super(parent, dataset, view_id, options); if (this.dataset.context.special_view) {     this.template = "MyViewManager"; } },
});

Greetings.

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
lis 15
3106
0
mar 15
4031
0
lut 24
4645
0
lis 17
4129
1
mar 16
6726