【问题标题】:JS Gantt chart is not loading from databaseJS 甘特图未从数据库加载
【发布时间】:2021-05-25 07:06:25
【问题描述】:

我正在尝试使用 DHTMLX 甘特图创建一个简单的示例。我已经设法让它工作,直到将数据存储在数据库中。数据被存储,但我无法在打开页面时加载图表。任何想法可能是什么问题?我浏览了可用的文档,但找不到这种行为的根本原因。

这是触发甘特图上的“保存”按钮后 SQL Server 的样子:

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 

GanttLoader.js 这里Gantt js被加载:

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:

@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");
    }
  }
}

在访问网页并加载图表时,我看到以下错误:

一直在关注他们的教程,但不知道我错过了什么。

【问题讨论】:

    标签: javascript c# asp.net blazor dhtmlx


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 2015-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多