Customize the Value and Text
Use the customizeText function if you need to customize the text displayed in cells.
Declare the calculateCellValue function to populate a column with custom values. This function is designed to create unbound columns - columns that are not bound to any individual data field. In the following example, this function combines full names from data that the firstName and lastName fields provide.
Note that sorting in unbound columns is disabled by default, and their cells can be edited at runtime only if you implement the setCellValue function.
Customize the Appearance
DevExtreme provides a markup component called dxTemplate for Angular, AngularJS and Knockout apps. The following code shows how you can customize column cells using this component. Note that the template's name is assigned to the column's cellTemplate option.
If you use jQuery alone, combine the HTML markup for cells using jQuery DOM manipulation methods. To apply this markup, use the cellTemplate function as shown in the following code:
- $(function() {
- $("#treeListContainer").dxTreeList({
- // ...
- columns: [{
- dataField: "Title",
- cellTemplate: function(element, info) {
- element.append("<div>" + info.text + "</div>")
- .css("color", "blue");
- }
- }]
- });
- });
While cellTemplate customizes data cells only, the onCellPrepared function can customize any cell. Unlike cellTemplate, this function does customizations after a cell is created, so you cannot use it to change the cell value. Check the rowType field of the function's argument to detect the UI element that owns the cell.
See Also
If you have technical questions, please create a support ticket in the DevExpress Support Center.