Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
4134 Lượt xem

I'm trying to load a graph timeline made by using vis.js, but i'm getting the error:

Traceback:
Error: No container provided
    at o.n._create (http://localhost:8069/web/content/500-8270a43/web.assets_backend.js:3316:153882)
    at new o (http://localhost:8069/web/content/500-8270a43/web.assets_backend.js:3316:99553)
    at http://localhost:8069/web/content/500-8270a43/web.assets_backend.js:3319:846
My js code:
odoo.define('test_timeline.timeline', function (require){    
    "use strict";
var core = require('web.core');
    var rpc = require('web.rpc');    
    var AbstractAction = require('web.AbstractAction');
var QWeb = core.qweb;
var TimelineDashboard = AbstractAction.extend({
        start: function(){            
            var self = this;            
                rpc.query({                
                    model: 'project.project',                
                    method: 'get_project_record', //call python function                
                    args: [],}).then((res) => {
                         var container = document.getElementById('visualization');
                         //will use res on Dataset                
                         var items = new vis.DataSet([                  
                                {id: 1, content: 'item 1', start: '2013-04-20'},                  
                                {id: 2, content: 'item 2', start: '2013-04-14'},                  
                                {id: 3, content: 'item 3', start: '2013-04-18'},                  
                                {id: 4, content: 'item 4', start: '2013-04-16', end: '2013-05-19'},                  
                                {id: 5, content: 'item 5', start: '2013-04-25'},
                                {id: 6, content: 'item 6', start: '2013-06-27'},
                                {id: 7, content: 'item 7', start: '2013-05-27'},                  
                                {id: 8, content: 'item 8', start: '2013-05-27'},]);
                // Configuration for the Timeline                
                                var options = {                  
                                        height: '500px'};// Create a Timeline
                                var timeline = new vis.Timeline(container, items, options);                
                                self.$el.append(QWeb.render('TimelineDashboard', {}))            
}) } }) core.action_registry.add('timeline', TimelineDashboard);
return TimelineDashboard;});

My xml:
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="TimelineDashboard">
    <div id="visualization"></div>
</t></templates>
I'm loading the vis lib through here:
<template id="gantt_timeline_assets" name="gantt assets" inherit_id="web.assets_backend">        
<xpath expr="." position="inside">
<script type="text/javascript" src="/test_timeline/static/lib/vis-timeline-graph2d.min.js"/>
<script type="text/javascript" src="/test_timeline/static/src/js/load_records.js"/> <!-- My js code-->
<link rel="stylesheet" href="/test_timeline/static/lib/vis-timeline-graph2d.min.css"/>
</xpath>
</template>
Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

I solved by just rendering the qweb before the vis.js code, my mistake. Just for the record: ODOO community barely answers my questions and the documentaction of the JS framework doesn't help much and because of the monolithic architecture I'm almost given up of using odoo.


Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
2
thg 2 20
5832
0
thg 12 19
4097
1
thg 6 24
3399
1
thg 3 22
1861
0
thg 8 21
3233