翻譯|使用教程|編輯:楊鵬連|2020-09-14 12:09:00.187|閱讀 314 次
概述:本文介紹了jQuery甘特包如何創(chuàng)建Angular Gantt示例?。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
jQuery Gantt Package是一個(gè)真正的跨平臺(tái),基于HTML5 / jQuery的本地實(shí)現(xiàn),具有2個(gè)不同的gantt小部件,可滿足您所有基于gantt的可視化需求。還帶有ASP.NET WebControl和MVC擴(kuò)展,可輕松集成到現(xiàn)有應(yīng)用中。
點(diǎn)擊下載jQuery Gantt Package試用版
-HTML模板樣本
項(xiàng)目甘特示例應(yīng)該使用元素“<rq:ganttcontrol></rq:ganttcontrol>”創(chuàng)建。
您可以設(shè)置甘特選項(xiàng),如Datasource, AnchorTime, ResizeToFit, UseVirtualization等,如這里所示。
gantt的數(shù)據(jù)源可以來自JSON,也可以來自本地函數(shù)(循環(huán)項(xiàng)源)。
應(yīng)該使用可用屬性創(chuàng)建甘特列。客戶端和編輯器模板使用'<ng-template></ng-template>'來指定絕對(duì)模板引用(前綴為'#'),如圖所示。
<RQ:GanttControl [DataSourceUrl]="'/app/Samples/GanttControlSkeleton/GanttControlSkeleton.json'" [AnchorTime]="'2018-02-02'" Height="500px" [ResizeToFit]="false" [AfterGanttWidgetInitializedCallback]="AfterGanttWidgetInitializedCallback"> <GanttTableOptions> <Columns> <Column field="Activity.ID" [width]="25" title="ID" [iseditable]="false"></Column> <Column field="Activity.ActivityName" [width]="200" title="Activity Name" [iseditable]="true" [isParentEditable]="true" [clientTemplate]="pgNameTemplate" [clientEditorTemplate]="pgNameEditorTemplate"></Column> <Column field="Activity.StartTime" [width]="150" title="StartTime" [format]="dateFormat" [clientEditorTemplate]="startTimeEditor"></Column> <Column field="Activity.EndTime" [width]="150" title="EndTime" [format]="dateFormat" [clientEditorTemplate]="endTimeEditor"></Column> <Column field="Activity.Effort" [width]="100" title="Effort" [clientTemplate]="effortTemplate" [clientEditorTemplate]="effortEditor"></Column> <Column field="Activity.ProgressPercent" [width]="100" title="ProgressPercent" [clientEditorTemplate]="progressPercentEditor"></Column> <Column field="Activity.PredecessorIndexString" [width]="100" title="Predecessor Index" [isParentEditable]="false" [clientTemplate]="predecessorIndexTemplate" [clientEditorTemplate]="predecessorIndexEditor"></Column> </Columns> </GanttTableOptions> </RQ:GanttControl> <!--Column Templates--> <ng-template #pgNameTemplate> <div #nameTemp> <div class="rq-grid-expand-indentWidth" [rqTemplateBinder]="nameColTempl.style_indentWidth"></div> <div class="arrowContainer" [rqTemplateBinder]="nameColTempl.style_arrowCont"> <div id="arrow" [rqTemplateBinder]="nameColTempl.class_arrow" onclick="RadiantQ.Gantt.ExpanderOnclick(this,event)"></div> </div> <div class="rq-grid-expander-text" data-bind="text:Activity.ActivityName"></div> <div [getClientTemplate]="nameTemp.innerHTML"></div> </div> </ng-template> <ng-template #effortTemplate> <div #effortTemp> <div [getClientTemplate]="effortTemp.innerHTML" data-bind="text:Activity.CumulativeEffort.toString()"></div> </div> </ng-template> <ng-template #predecessorIndexTemplate> <div #predTemp> <div [getClientTemplate]="predTemp.innerHTML" data-bind='text:Activity.PredecessorIndexString'></div> </div> </ng-template> <!--Column Editors--> <ng-template #pgNameEditorTemplate> <div #nameEditor> <div class="rq-grid-expand-indentWidth" [rqTemplateBinder]="nameColTempl.style_indentWidth"></div> <div [rqTemplateBinder]="nameColTempl.style_arrowCont" class="arrowContainer"> <div id="arrow" onclick="RadiantQ.Gantt.ExpanderOnclick(this,event)" [rqTemplateBinder]="nameColTempl.class_arrow"></div> </div> <div class="rq-grid-expander-text"><input data-bind=value:Activity.ActivityName /></div> <div [getClientEditorTemplate]="nameEditor.innerHTML"></div> </div> </ng-template> <ng-template #startTimeEditor> <div #startEditor> <input [getClientEditorTemplate]="startEditor.innerHTML" data-bind='ActivityTimeBinder:Activity.StartTime' /> </div> </ng-template> <ng-template #endTimeEditor> <div #endEditor> <input [getClientEditorTemplate]="endEditor.innerHTML" data-bind='value:Activity.EndTime' data-getvalueName='getDate' data-setvaluename='setDate' data-valueUpdate='onBlur' data-role="DateTimePicker" /> </div> </ng-template> <ng-template #effortEditor> <div #effEditor> <input [getClientEditorTemplate]="effEditor.innerHTML" data-bind='value:Activity.Effort' data-role="DurationPicker" /> </div> </ng-template> <ng-template #progressPercentEditor> <div #progressEditor> <input [getClientEditorTemplate]="progressEditor.innerHTML" data-bind='value:Activity.ProgressPercent' data-role="spinner" data-options='{"min": 0, "max": 100}' /> </div> </ng-template> <ng-template #predecessorIndexEditor> <div #predEditor> <input [getClientEditorTemplate]="predEditor.innerHTML" data-bind='value:Activity.PredecessorIndexString' /> </div> </ng-template>-JSON示例數(shù)據(jù)
[{ "Name" : "Task 1", "ID" : 1, "StartTime" : "2018-02-02T00:00:00Z", "Effort" : "8:00:00", "Resources" :"1", "Description" : "Description of Task 1" }, { "Name" : "Task 2", "ID" : 2, "PredecessorIndices" : "1", "StartTime" : "2018-02-03T00:00:00Z", "Effort" : "16:00:00", "Resources" :"1", "Description" : "Description of Task 2" }, { "Name" : "Task 3", "ID" : 3, "StartTime" : "2018-02-02T00:00:00Z", "Effort" : "1.12:30:00", "ProgressPercent" : 90, "Description" : "Description of Task 3" }, { "Name" : "Child Task 1", "ID" : 4, "IndentLevel" : 1, "StartTime" : "2018-02-03T00:00:00Z", "Effort" : "8:00:00", "ProgressPercent" : 100, "Description" : "Description of Task 3/Child Task 1" }, { "Name" : "Child Task 2", "ID" : 5, "IndentLevel" : 1, "PredecessorIndices" : "4+8", "Description" : "Description of Task 3/Child Task 2" }, { "Name" : "Grand Child Task 1", "ID" : 6, "IndentLevel" : 2, "StartTime" : "2018-02-03T00:00:00Z", "Effort" : "8:00:00", "Description" : "Description of Task 3/Child Task 1/Grand Child 1" }, { "Name" : "Grand Child Task 2", "ID" : 7, "IndentLevel" : 2, "StartTime" : "2018-02-03T00:00:00Z", "Effort" : "16:00:00", "Description" : "Description of Task 3/Child Task 1/Grand Child 2" }, { "Name" : "Child Task 3", "ID" : 8, "IndentLevel" : 1, "StartTime" : "2018-02-02T00:00:00Z", "Effort" : "16:00:00", "Description" : "Description of Task 3/Child Task 3" }, { "Name" : "Task 4", "ID" : 9, "StartTime" : "2018-02-02T00:00:00Z", "Effort" : "00:00:00", "ProgressPercent" : 60, "Description" : "Description of Task 4" }, { "Name" : "Task 5", "ID" : 10, "StartTime" : "2018-02-02T00:00:00Z", "Effort" : "8:00:00", "PredecessorIndices" : "3+8,9", "Description" : "Description of Task 5" }, { "Name" : "Child Task 1", "ID" : 11, "IndentLevel" : 1, "StartTime" : "2018-02-02T00:00:00Z", "Effort" : "1.16:00:00", "Description" : "Description of Task 5/Child Task 1" }, { "Name" : "Child Task 2", "ID" : 12, "PredecessorIndices" : "11+8", "IndentLevel" : 1, "StartTime" : "2018-02-02T00:00:00Z", "Effort" : "8:00:00", "Description" : "Description of Task 5/Child Task 2" }, { "Name" : "Task 6", "ID" : 13, "StartTime" : "2018-02-02T00:00:00Z", "Effort" : "1.16:00:00", "Description" : "Description of Task 6" }, { "Name" : "Child Task 1", "ID" : 14, "IndentLevel" : 1, "StartTime" : "2018-02-02T00:00:00Z", "Effort" : "1.20:00:00", "Description" : "Description of Task 6/Child Task 1" }, { "Name" : "Grand Child Task 1", "ID" : 15, "StartTime" : "2018-02-04T00:00:00Z", "Effort" : "1.00:00:00", "IndentLevel" : 2, "Resources" :"1 , 2", "Description" : "Description of Task 6/Child Task 2" }] GanttControlSkeleton.json樣例TS
“GanttControlSkeleton.ts的文件從頂級(jí)的ts文件夾中導(dǎo)入TypeScript庫。
示例模板(GanttControlSkeleton.html)及其對(duì)應(yīng)的CSS(GanttControlSkeleton. CSS)可以使用“@Component({})”裝飾器聲明,選擇器為“ganttcontrol骨架”,在index.html中指定為示例根標(biāo)簽
這里,export類傳遞甘特選項(xiàng)的值,甘特選項(xiàng)在'GanttControlSkeleton中設(shè)置為模板。例如DataSource, AnchorTime, ResizetoFit, Columns和bindings。
/// <reference path="../../../ts/radiantqgantt_ts2.3.d.ts" /> /// <reference path="../../../ts/jquery.ui.d.ts" /> /// <reference path="../../../ts/datejs.d.ts" /> import { Component, ElementRef, ViewEncapsulation } from '@angular/core'; @Component({ selector: 'GanttControlSkeleton', templateUrl: './app/Samples/GanttControlSkeleton/GanttControlSkeleton.html', styleUrls: ['./app/Samples/GanttControlSkeleton/GanttControlSkeleton.css'], encapsulation: ViewEncapsulation.None, // Fix: Styles for child elements not applied due to encapsulation(shadow dom). }) export class GanttControlSkeleton { private $gcSkeleton: HTMLElement = null; nameColTempl = { style_indentWidth: { key: 'style', value: 'height: 1px; width: ${data.IndentWidth_M()}px' }, style_arrowCont: { key: 'style', value: 'width: 12px; display: ${data.IsParent_M() ? \"block"\ :\"none"\ }' }, class_arrow: { key: 'class', value: '${ data.IsExpanded_M() ? \" rq-grid-expand-arrow rq-grid-collapse-arrow"\: \"rq-grid-expand-arrow"\} rq-Ignore-click' } }; dateFormat = Date["CultureInfo"]["formatPatterns"]["shortDate"]; constructor(private elementRef: ElementRef) { this.$gcSkeleton = elementRef.nativeElement; } AfterGanttWidgetInitializedCallback($gantt_container: any) { // This gets fired once after the gantt widget is intialized with user options. var ganttControl = $gantt_container.data('GanttControl'); // Here, user can customize the gantt using this 'ganttControl' instance. }; }“AfterGanttWidgetInitializedCallback”函數(shù)在使用用戶選項(xiàng)初始化甘特小部件后觸發(fā)一次。在這里,用戶可以使用“ganttControl”實(shí)例自定義甘特
甘特部件初始化過程在'RQGanttSettings中進(jìn)行。帶有用戶選項(xiàng)的ts'。
以下路徑說明了這一點(diǎn):
Angular中
:\PlatformSamples\AngularSamples\app\Samples\GanttControlSkeleton\..
此外,通過以下路徑在一個(gè)頁面中導(dǎo)入“GanttControl和FlexyGantt”示例:
Angular中
in:\PlatformSamples\AngularSamples\app\Samples\ResourceLoadView\…
相關(guān)產(chǎn)品介紹:
VARCHART XGantt:支持ActiveX、.Net等平臺(tái)的C#甘特圖控件
AnyGantt:構(gòu)建復(fù)雜且內(nèi)容豐富的甘特圖的理想工具
phGantt Time Package:對(duì)任務(wù)和時(shí)間的分配管理的甘特圖
dhtmlxGantt:交互式JavaScript / HTML5甘特圖
APS是慧都科技15年行業(yè)經(jīng)驗(yàn)以及技術(shù)沉淀之作,通過連接企業(yè)接單、采購、制造、倉儲(chǔ)物流等整個(gè)供應(yīng)鏈流程,幫助提升企業(yè)生產(chǎn)效率。>>查看APS詳細(xì)信息
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自: