Available in the Full Version
Tree Grid - TypeScript
This sample demonstrates how to create and configure an igTreeGrid with row selection and local sorting features in TypeScript.
This sample uses CTP (Community Technical Preview) features. The API and behavior may change when these features are released with full support.
This sample is designed for a larger screen size.
On mobile, try rotating your screen, view full size, or email to another device.
The data being used is hierarchical and is passed as an array of custom type HierarchicalTask that contains HierarchicalTasks in itself.
Code View
Copy to Clipboard
<!DOCTYPE html> <html> <head> <title></title> <!-- Ignite UI for jQuery Required Combined CSS Files --> <link href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" /> <link href="http://cdn-na.infragistics.com/igniteui/2024.1/latest/css/structure/infragistics.css" rel="stylesheet" /> <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script> <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script> <!-- Ignite UI for jQuery Required Combined JavaScript Files --> <script src="http://cdn-na.infragistics.com/igniteui/2024.1/latest/js/infragistics.core.js"></script> <script src="http://cdn-na.infragistics.com/igniteui/2024.1/latest/js/infragistics.lob.js"></script> </head> <body> <div id="treegrid"></div> <script src="/TypeScriptSamples/tree-grid/typescript.js"></script> </body> </html>
/// <reference path="/js/typings/jquery.d.ts" /> /// <reference path="/js/typings/jqueryui.d.ts" /> /// <reference path="/js/typings/igniteui.d.ts" /> class HierarchialTask { id: number; taskName: string; start: string; finish: string; duration: string; progress: string; products: HierarchialTask[]; constructor(public _id, public _taskName, public _start, public _finish, public _duration, public _progress, public _products) { this.id = _id; this.taskName = _taskName; this.start = _start; this.finish = _finish; this.duration = _duration; this.progress = _progress; this.products = _products; } } var designTasks: HierarchialTask[] = []; designTasks.push(new HierarchialTask(8, "Conceptual Design", "6/13/2014", "6/16/2014", "2d", "100%", [])); designTasks.push(new HierarchialTask(9, "Preliminary Design", "6/17/2014", "6/18/2014", "2d", "65%", [])); designTasks.push(new HierarchialTask(10, "Final Design", "6/19/2014", "6/19/2014", "1d", "15%", [])); var devTasks: HierarchialTask[] = []; devTasks.push(new HierarchialTask(11, "Implementation", "6/20/2014", "7/17/2014", "20d", "5%", [])); devTasks.push(new HierarchialTask(12, "Testing", "7/18/2014", "7/31/2014", "10d", "0%", [])); devTasks.push(new HierarchialTask(13, "Bug fixing", "8/1/2014", "8/14/2014", "10d", "0%", [])); devTasks.push(new HierarchialTask(14, "Documenting", "8/15/2014", "8/20/2014", "4d", "0%", [])); var designMainTask = new HierarchialTask(5, "Design", "6/13/2014", "6/19/2014", "5d", "60%", designTasks); var devMainTask = new HierarchialTask(6, "Development", "6/20/2014", "8/20/2014", "44d", "5%", devTasks); var projectTask: HierarchialTask[] = []; projectTask.push(new HierarchialTask(0, "Project Plan", "6/2/2014", "8/22/2014", "60d", "32%", [])); projectTask.push(new HierarchialTask(1, "Planning", "6/2/2014", "6/4/2014", "3d", "100%", [])); projectTask.push(new HierarchialTask(2, "Write a specification", "6/5/2014", "6/6/2014", "2d", "100%", [])); projectTask.push(new HierarchialTask(3, "Create a demo application", "6/9/2014", "6/11/2014", "3d", "100%", [])); projectTask.push(new HierarchialTask(4, "Collect a feedback", "6/12/2014", "6/12/2014", "1d","100%", [])); projectTask.push(designMainTask); projectTask.push(devMainTask); projectTask.push(new HierarchialTask(7, "Project Complete", "8/21/2014", "8/22/2014", "2d", "0%", [])); $(function () { $("#treegrid").igTreeGrid({ width: "100%", dataSource: projectTask, //Project Plan data, autoGenerateColumns: false, primaryKey: "id", columns: [ { headerText: "ID", key: "id", width: "15%", dataType: "number" }, { headerText: "Tasks", key: "taskName", width: "25%", dataType: "string" }, { headerText: "Start", key: "start", width: "15%", dataType: "string" }, { headerText: "Finish", key: "finish", width: "15%", dataType: "string" }, { headerText: "Duration", key: "duration", width: "15%", dataType: "string" }, { headerText: "Progress", key: "progress", width: "15%", dataType: "string" } ], childDataKey: "products", initialExpandDepth: 1, features: [ { name: "Selection", }, { name: "Sorting", type: "local" }, { name: "RowSelectors", rowSelectorColumnWidth: 80, enableCheckBoxes: true, checkBoxMode: "triState" } ] }); })