翻譯|使用教程|編輯:楊鵬連|2020-08-10 13:57:12.870|閱讀 215 次
概述:本教程為您提供有關(guān)如何在服務(wù)器端使用ASP.NET Core 2 創(chuàng)建Gantt的分步說(shuō)明。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
dhtmlxGantt是用于跨瀏覽器和跨平臺(tái)應(yīng)用程序的功能齊全的Gantt圖表。可滿(mǎn)足項(xiàng)目管理應(yīng)用程序的所有需求,是最完善的甘特圖圖表庫(kù)。它允許你創(chuàng)建動(dòng)態(tài)甘特圖,并以一個(gè)方便的圖形化方式可視化項(xiàng)目進(jìn)度。有了dhtmlxGantt,你可以顯示活動(dòng)之間的依賴(lài)關(guān)系,顯示具有完成百分比陰影的當(dāng)前任務(wù)狀態(tài)以及組織活動(dòng)到樹(shù)結(jié)構(gòu)。
步驟1.創(chuàng)建一個(gè)項(xiàng)目
啟動(dòng)Visual Studio 2017并創(chuàng)建一個(gè)新項(xiàng)目。打開(kāi)文件菜單,然后選擇:新建->項(xiàng)目。
接下來(lái),選擇ASP.NET Core Web Application,并將其命名為DHX.Gantt。
選擇一個(gè)空模板。
因此,您已經(jīng)創(chuàng)建了一個(gè)項(xiàng)目,可以繼續(xù)為Gantt添加標(biāo)記和腳本。
步驟2.添加甘特標(biāo)記和JS轉(zhuǎn)到wwwroot并創(chuàng)建一個(gè)index.html文件。
請(qǐng)注意,在此演示中,從CDN添加了甘特文件。如果您擁有該組件的專(zhuān)業(yè)版,則需要手動(dòng)將gantt文件添加到您的項(xiàng)目中。
index.html <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width" /> <title>Index</title> <link rel="stylesheet" type="text/css" /> <script src="http://cdn.dhtmlx.com/gantt/edge/dhtmlxgantt.js"></script> <script> document.addEventListener("DOMContentLoaded", function(event) { // 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"); }); </script> </head> <body> <div id="gantt_here" style="width: 100%; height: 100vh;"></div> </body> </html>加載頁(yè)面時(shí),除了初始化甘特圖 之外,還會(huì)立即調(diào)用數(shù)據(jù)加載并進(jìn)行 dataProcessor設(shè)置,因此,用戶(hù)對(duì)甘特圖所做的所有更改都將保存到后端。后端尚未實(shí)現(xiàn),因此以后會(huì)更有意義。
接下來(lái)轉(zhuǎn)到Startup.cs,并告訴應(yīng)用程序使用index.html頁(yè)面。為此,您需要配置該應(yīng)用程序以從該wwwroot文件夾提供靜態(tài)文件。它在實(shí)現(xiàn)Configure方法調(diào)用的app.UseStaticFiles()方法。您可以在此處找到更多詳細(xì)信息。
我們還需要通過(guò)將方法中的“ Hello world”存根替換為突出顯示的兩行代碼,來(lái)將所需的中間件添加到Startup.csConfigure():
Startup.cs using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.DependencyInjection; namespace DHX.Gantt { public class Startup { // This method gets called by the runtime. // Use this method to add services to the container. // For more information on how to configure your application, // visit //go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { } // This method gets called by the runtime. // Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseDefaultFiles(); app.UseStaticFiles(); } } }添加的2個(gè)中間件是:
是否想嘗試DHTMLX Gantt來(lái)構(gòu)建自己的Salesforce應(yīng)用?訪(fǎng)問(wèn)我們的GitHub存儲(chǔ)庫(kù),您可以在其中找到Salesforce的Gantt組件的完整源代碼,并按照我們的視頻指南中的步驟進(jìn)行操作。
關(guān)產(chǎn)品推薦:
VARCHART XGantt:支持ActiveX、.Net等平臺(tái)的C#甘特圖控件
AnyGantt:構(gòu)建復(fù)雜且內(nèi)容豐富的甘特圖的理想工具
jQuery Gantt Package:基于HTML5 / jQuery的跨平臺(tái)jQuery Gantt包
phGantt Time Package:對(duì)任務(wù)和時(shí)間的分配管理的甘特圖
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: