cancel
Showing results for 
Search instead for 
Did you mean: 

center align all widgets in dashboard

gyanianand
8 - Cloud Apps
8 - Cloud Apps

dashboard.on('widgetready', function (se, ev) {

// Widget IDs
var widgetIds = ['645216bac5715a00355a81b5', '645cc852c5715a00355b12ec', '64631a30c5715a00355b35c6',"646339bcc5715a00355b365f","64633ac6c5715a00355b3668","64633bd5c5715a00355b367b"]; // Add more IDs as needed

// Iterate over each widget ID
widgetIds.forEach(function(widgetid) {

if (ev.widget.oid == widgetid) {
var pivotWidth = parseFloat($('[widgetid=' + widgetid + '] pivot2 .pivot-container .multi-grid .pivot-scroller .table-grid', element).width());
var containerWidth = parseFloat($('[widgetid=' + widgetid + '] pivot2 .pivot-container', element).width());

if (pivotWidth < containerWidth)
$('[widgetid=' + widgetid + '] pivot2 .pivot-container', element).css('margin-left', 'calc(50% - ' + (pivotWidth / 2) + 'px)');
}

});
});

1 REPLY 1

Sijo1995
9 - Travel Pro
9 - Travel Pro

Hi @gyanianand ,

Please try this script

dashboard.on('widgetready', function (se, ev) {
  // Get all the widgets in the dashboard
  var widgets = dashboard.getWidgets();

  // Loop through all the widgets
  for (var i = 0; i < widgets.length; i++) {
    // Center align the widget
    widgets[i].setAlignment('Center');
  }
});

Thanks

Sijo