首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JS甘特图没有从数据库加载

JS甘特图没有从数据库加载
EN

Stack Overflow用户
提问于 2021-05-25 07:06:25
回答 1查看 211关注 0票数 0

我正在尝试用DHTMLX甘特创建一个简单的例子。我已经设法让它工作,直到将数据存储在数据库中。数据会被存储,但我无法在打开页面时加载图表。有什么好主意吗?我已经看过了可用的文档,但是我找不到造成这种行为的根本原因。

触发甘特图上的Save按钮后,SQL Server是这样的:

代码语言:javascript
复制
5   New task    21.5.2021 0.00.00   1   0,0000  0   NULL    0
6   Joiuwqeowqe 21.5.2021 0.00.00   6   0,0000  0   NULL    0
7   New task    21.5.2021 0.00.00   4   0,0000  0   NULL    0
8   New task    21.5.2021 0.00.00   1   0,0000  0   NULL    0
9   New task    21.5.2021 0.00.00   1   0,0000  0   NULL    0
10  New task    21.5.2021 0.00.00   1   0,0000  0   NULL    0
NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL 

这里加载了甘特js的GanttLoader.js:

代码语言:javascript
复制
import 'https://cdn.dhtmlx.com/gantt/edge/dhtmlxgantt.js';

// ../gantt-master/codebase/dhtmlxgantt.js
// https://cdn.dhtmlx.com/gantt/edge/dhtmlxgantt.js

export function InitDHTML() {


  // specifying the date format
  gantt.config.date_format = "%Y-%m-%d %H:%i";
  // initializing gantt
  gantt.init("gantt_here");
  // initiating data loading
  gantt.load("/api/data");
  // initializing dataProcessor
  var dp = new gantt.dataProcessor("/api/");
  // and attaching it to gantt
  dp.init(gantt);
  // setting the REST mode for dataProcessor
  dp.setTransactionMode("REST");
}

Index.razor:

代码语言:javascript
复制
@page "/gantt"

<h3>Gantt</h3>

<div id="gantt_here" style="width: 100%; height: 100vh;"></div>

@inject IJSRuntime JS
@code{
  private IJSObjectReference importedDHTML;
  protected override async Task OnAfterRenderAsync(bool firstRender)
  {
    if (firstRender)
    {
      // import the script from the file
      importedDHTML = await JS.InvokeAsync<IJSObjectReference>(
          "import", "./GanttLoader.js");

      // Initialize dhtmlxgantt
      await importedDHTML.InvokeAsync<IJSObjectReference>(
          "InitDHTML");
    }
  }
}

在浏览网页和加载图表时,我看到以下错误:

一直在学习他们的教程,不知道我错过了什么。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-05-26 14:47:18

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67683227

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档