The first step is to create html page and add links to the javascript files and css dependencies to your project. The TreeGrid widget requires the following files:
jqxTreeGrid uses jQuery for basic JavaScript tasks like elements selection and events handling. You need to include the jQuery javascript file, the jQWidgets core framework file - jqxcore.js, the jQWidgets data binding file - jqxdata.js, the main jqxTreeGrid plug-in file - jqxtreegrid.js file, the jQWidgets DataTable file - jqxdatatable.js, the jQWidgets Scrollbar plug-in - jqxbutton.js and jqxscrollbar.js(used for the TreeGrid scrolling), jQWidgets DropDownList plug-in(used in the TreeGrid's Pager and Filtering panel) - jqxlistbox.js and jqxdropdownlist.js, and the base jQWidgets stylesheet - jqx.base.css:
$("#treeGrid").jqxTreeGrid({ disabled: true});
To get a property(option), you need to pass the property name to the jqxTreeGrid's
constructor.
var disabled = $("#treeGrid").jqxTreeGrid('disabled');
To call a function, you need to pass the function name and parameters(if any).
$("#treeGrid").jqxTreeGrid('selectRow', 1);
To attach an event handler function to the jqxTreeGrid widget, you can use the jQuery's .on() method. Let’s suppose
that you want to write code which does something when the user selects a row. The example code below demonstrates
how to bind to the ‘rowSelect’ event of jqxTreeGrid.
$("#treeGrid").on('rowSelect', function (event) {
// event arguments
var args = event.args;
// row data
var rowData = args.row;
// row key
var rowKey = args.key;
});
Most of the browser events bubble from the element(the event target) where they occur up to the body and the document element.
By default, most events bubble up from the original event target to the document element. At each element along the way, jQuery calls any matching event handlers that have been attached. An event handler can prevent the event from bubbling further up the document tree (and thus prevent handlers on those elements from running) by calling event.stopPropagation(). Any other handlers attached on the current element will run however. To prevent that, call event.stopImmediatePropagation(). (Event handlers bound to an element are called in the same order that they were bound.)
$("#treeGrid").on('rowSelect', function (event) {
// event arguments
var args = event.args;
// row data
var rowData = args.row;
// row key
var rowKey = args.key;
event.stopPropagation();
});