DataViewsJS allows you to apply presenters to column data to enhance the visual appearance of the grid. The column presenter definition uses doT.js syntax. The doT.js syntax is a fast and concise JavaScript template function with emphasis on performance. Learn more about doT.js at http://olado.github.io/doT/index.html.
Use the following steps to apply Checkbox and DataBar presenters to the grid columns.
These steps assume that you have already initialized the grid and defined the columns. See Creating a Basic Grid and Defining Columns for additional information.
var percentCompleteColPresenter = '<span class="percent-complete-bar" style="background-color:\{{? it.percentComplete<30}}#FE4A49\{{?? it.percentComplete<60}}#FED766\{{??}}#009FB7\{{?}};width:\{{=it.percentComplete}}%;"></span>'; var percentCompleteColPresenter2 = '<span style="display:inline-block;width:\{{=it.percentComplete}}px;"></span>';
var booleanColPresenter = '<input type="checkbox" disabled="disabled" \{{? it.billable}}checked\{{?}} />';
var columns = [ { id: 'title', caption: 'Title', dataField: 'title', }, { id: 'duration', caption: 'Duration', dataField: 'duration', presenter: durationPresenter, cssClass: getColClass, }, { id: 'percentComplete', caption: '% Complete', dataField: 'percentComplete', presenter: percentCompleteColPresenter, }, { id: 'percentComplete1', caption: '% Complete', dataField: 'percentComplete', presenter: percentCompleteColPresenter2, cssClass: getColClass, width: 100, allowResizing: false, }, { id: 'start', caption: 'Start', dataField: 'start', format: 'mm/dd/yyyy', visible: !hiddenColumn, }, { id: 'finish', caption: 'Finish', dataField: 'finish', format: 'mm/dd/yyyy', visible: !hiddenColumn, }, { id: 'billable', caption: 'Billable', dataField: 'billable', presenter: booleanColPresenter, visible: !hiddenColumn, }, ];
Submit and view feedback for