You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.4 KiB

/*
* The PMLeafNameCellRenderer is a custom cell renderer for the names of leaf nodes in the pinned table so that they
* are truncated to the proper number of characters
*/
define(['/static/app/DA-ITSI-CP-vmware-dashboards/libs/backbone.js', "/static/app/DA-ITSI-CP-vmware-dashboards/swc-vmware-cp/index.js", '/static/app/DA-ITSI-CP-vmware-dashboards/libs/underscore.js'],
function ( Backbone, SWCVMware, _) {
const TableView = SWCVMware.TableView;
const Visualizations = SWCVMware.Visualizations;
const VisualizationRegistry = SWCVMware.VisualizationRegistry;
const visualizationsCollection = new Visualizations();
const vizDfd = visualizationsCollection.fetch({data: {count: -1}});
var LeafNameCellRenderer = TableView.BaseCellRenderer.extend({
canRender: function(cell) {
return cell.field === 'name';
},
_clipName: function(name) {
if (name === null || name === undefined) {
name = "";
}
if (name.length > 24) {
//Display only upto 16 chars of the name label
var short_name = name.substr(0, 20);
return short_name.concat('...');
} else {
return name;
}
},
// This render function only works when canRender returns 'true'
render: function($td, cell) {
$td.css("font-size", "10px");
$td.html(this._clipName(cell.value));
}
});
return LeafNameCellRenderer;
});