项目作者: anik123

项目描述 :
A directive which will maintain dhtmlx gantt in angularjs
高级语言: JavaScript
项目地址: git://github.com/anik123/Dhtmlx-Gantt-Directive-in-angularjs.git


Dhtmlx Gantt Directive in angularjs

A directive which will maintain dhtmlx gantt in angularjs.

What is Dhtmlx Gantt ?

dhtmlxGantt is an open source JavaScript Gantt chart that helps you visualize a project schedule in a nice-looking chart. It can show the dependencies between tasks as lines and allows you to set up different relationships between tasks (finish-to-start, start-to-start, end-to-end). dhtmlxGantt provides flexible API and a large number of event handles, which gives you the freedom to customize it for your needs.

Settings

This directive’s scope is isolated.

This is the config object which will be passed from controler.

  1. $scope.granttConfig = {
  2. dataSource: $scope.tasks,
  3. config: {
  4. columns: columnConfig,
  5. show_chart: true
  6. }
  7. }

Html binding

  1. <div ng-grantt="granttConfig" action="action($data,$action)"></div>

Action method

  1. $scope.action = function($data, $action) {
  2. console.log($data);
  3. console.log($action);
  4. }
  • $data will send selected object
  • $action will send performed action (Add,Edit,Delete)

Data Design of dhtmlx grantt is

  1. $scope.tasks = {
  2. data: [{
  3. id: 1,
  4. text: "Project #2",
  5. start_date: "01-04-2013",
  6. duration: 18,
  7. tree: true
  8. }, {
  9. id: 2,
  10. text: "Task #1",
  11. start_date: "02-04-2013",
  12. duration: 8,
  13. progress: 0.6,
  14. parent: 1
  15. }, {
  16. id: 3,
  17. text: "Task #2",
  18. start_date: "11-04-2013",
  19. duration: 8,
  20. progress: 0.6,
  21. parent: 1
  22. }],
  23. links: [{
  24. id: 1,
  25. source: 1,
  26. target: 2,
  27. type: 1
  28. }, {
  29. id: 2,
  30. source: 2,
  31. target: 3,
  32. type: 0
  33. }]
  34. };

In tasks object’s data property will hold infomation of data and link property will hold information of link between the tasks in the chart.

In directive , configuration are used from dhtmlx gantt docs.

  1. var config = $scope.ngGrantt.config || {}; // setting config
  2. gantt.config.show_task_cells = false;
  3. gantt.config.autofit = true;
  4. gantt.config.readonly = typeof config.readonly == "undefined" ? true : config.readonly;
  5. gantt.config.show_progress = typeof config.show_progress == "undefined" ? false : config.show_progress;
  6. gantt.config.show_chart = typeof config.show_chart == "undefined" ? false : config.show_chart;
  7. gantt.config.show_grid = typeof config.show_grid == "undefined" ? true : config.show_grid;
  8. gantt.config.open_tree_initially = typeof config.open_tree_initially == "undefined" ? true : config.open_tree_initially;

Demo

  • Dhtmlx Gantt without chart

Without chart

  • Dhtmlx Gantt with chart

With chart