All Components

Gantt / Column resizing

HTML5/JavaScript 源码

<!DOCTYPE html>
<html>
 <head> 
  <title>Column resizing</title> 
  <meta charset="utf-8"> 
  <link href="../content/shared/styles/examples-offline.css" rel="stylesheet"> 
  <link href="../../styles/kendo.common.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.rtl.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.default.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.dataviz.min.css" rel="stylesheet"> 
  <link href="../../styles/kendo.dataviz.default.min.css" rel="stylesheet"> 
  <script src="../../js/jquery.min.js"></script> 
  <script src="../../js/kendo.all.min.js"></script> 
  <script src="../content/shared/js/console.js"></script> 
  <script>
        
    </script> 
 </head> 
 <body> 
  <a class="offline-button" href="../index.html">Back</a> 
  <div id="example"> 
   <div id="gantt"></div> 
   <script>
            $(document).ready(function() {
                var serviceRoot = "//demos.telerik.com/kendo-ui/service";
                var tasksDataSource = new kendo.data.GanttDataSource({
                    transport: {
                        read: {
                            url: serviceRoot + "/GanttTasks",
                            dataType: "jsonp"
                        },
                        update: {
                            url: serviceRoot + "/GanttTasks/Update",
                            dataType: "jsonp"
                        },
                        destroy: {
                            url: serviceRoot + "/GanttTasks/Destroy",
                            dataType: "jsonp"
                        },
                        create: {
                            url: serviceRoot + "/GanttTasks/Create",
                            dataType: "jsonp"
                        },
                        parameterMap: function(options, operation) {
                            if (operation !== "read") {
                                return { models: kendo.stringify(options.models || [options]) };
                            }
                        }
                    },
                    schema: {
                        model: {
                            id: "id",
                            fields: {
                                id: { from: "ID", type: "number" },
                                orderId: { from: "OrderID", type: "number", validation: { required: true } },
                                parentId: { from: "ParentID", type: "number", defaultValue: null, validation: { required: true } },
                                start: { from: "Start", type: "date" },
                                end: { from: "End", type: "date" },
                                title: { from: "Title", defaultValue: "", type: "string" },
                                percentComplete: { from: "PercentComplete", type: "number" },
                                summary: { from: "Summary", type: "boolean" },
                                expanded: { from: "Expanded", type: "boolean", defaultValue: true }
                            }
                        }
                    }
                });

                var dependenciesDataSource = new kendo.data.GanttDependencyDataSource({
                    transport: {
                        read: {
                            url: serviceRoot + "/GanttDependencies",
                            dataType: "jsonp"
                        },
                        update: {
                            url: serviceRoot + "/GanttDependencies/Update",
                            dataType: "jsonp"
                        },
                        destroy: {
                            url: serviceRoot + "/GanttDependencies/Destroy",
                            dataType: "jsonp"
                        },
                        create: {
                            url: serviceRoot + "/GanttDependencies/Create",
                            dataType: "jsonp"
                        },
                        parameterMap: function(options, operation) {
                            if (operation !== "read") {
                                return { models: kendo.stringify(options.models || [options]) };
                            }
                        }
                    },
                    schema: {
                        model: {
                            id: "id",
                            fields: {
                                id: { from: "ID", type: "number" },
                                predecessorId: { from: "PredecessorID", type: "number" },
                                successorId: { from: "SuccessorID", type: "number" },
                                type: { from: "Type", type: "number" }
                            }
                        }
                    }
                });

                var gantt = $("#gantt").kendoGantt({
                    dataSource: tasksDataSource,
                    dependencies: dependenciesDataSource,
                    views: [
                        "day",
                        { type: "week", selected: true },
                        "month"
                    ],
                    columns: [
                        { field: "id", title: "ID", width: 60 },
                        { field: "title", title: "Title", editable: true, sortable: true },
                        { field: "start", title: "Start Time", format: "{0:MM/dd/yyyy}", width: 100, editable: true, sortable: true },
                        { field: "end", title: "End Time", format: "{0:MM/dd/yyyy}", width: 100, editable: true, sortable: true }
                    ],
                    height: 700,

                    showWorkHours: false,
                    showWorkDays: false,

                    resizable: true,

                    snap: false
                }).data("kendoGantt");

                $(document).bind("kendo:skinChange", function() {
                    gantt.refresh();
                });
            });
        </script> 
  </div>   
 </body>
</html>