jsGanttImproved / ng-gantt

Gantt for Angular 8 based on jsgantt-improved
MIT License
61 stars 28 forks source link

Default options not working #9

Closed BlackTango closed 5 years ago

BlackTango commented 5 years ago

The initial options are not loading correctly

This is in the html: <ng-gantt [options]="editorOptions" [data]="gantt_projects" #editor></ng-gantt>

This is in the ts file: editorOptions = { vShowRes: parseInt('0', 10), vTooltipDelay: 50, vScrollTo: "today", vShowStartDate: parseInt('0', 10), vShowEndDate: parseInt('0', 10), }

None of these options are actually working on startup. I need to manually run for it to work : this.editor.setOptions(this.editorOptions)

mariohmol commented 5 years ago

@jonathanlassen check it out.. the module for angular.. if you would like to start coding on angular

mariohmol commented 5 years ago

Hi.. i have this working in demo.. i can even change and see on the screen.. check it out

https://github.com/jsGanttImproved/ng-gantt/blob/master/src/app/demo/demo.component.ts#L125

mariohmol commented 5 years ago

I.. have this workin on stackblitz as well.. check it out https://stackblitz.com/edit/angular-ng-gantt?file=src%2Fapp%2Fapp.component.ts

BlackTango commented 5 years ago

Hi, thank you for your reply. The stackblitz example have no options. When i try to add options and run this.editor.setOptions(this.editorOptions) an error appear.

ERROR TypeError: Cannot read property 'setOptions' of undefined

I think the editor is not initialised in ngOnInit().

mariohmol commented 5 years ago

I dont know what happent.. was not saved.. i saved the stackblitz againa

https://stackblitz.com/edit/angular-ng-gantt

BlackTango commented 5 years ago

Thank you, it works. Really appreciated!

vishal-shetty commented 4 years ago

this.editor.setOptions(this.editorOptions)

Thanks for this line of code. This worked in subscribe method in angular. Whereas directly putting this.editorOptions in subscribe was not working. Why this.editorOptions doesn't work inside subscribe method? Also I think this is not mentioned in the documentation of ng-gantt

mariohmol commented 4 years ago

Uhmm maybe because you are changing a inner value for the editor? If you change the data variable or the editor var (this.editor = { ..} ) , this should trigger the rerender