Ticket T245498
Visible to All Users

How to align a grid field

created 10 years ago

Hi, in the grid (example attach), how I can align a field? (right or left)…
thanks!

Answers approved by DevExpress Support

created 10 years ago (modified 10 years ago)

At present our Dashboards does not provide a capability to specify grid columns alignment in designer.
However you can change these settings in dashboard viewer getting an access to the inner grid control.
To change column and cell headers  alignment to right in WinForms DashboardViewer use the following code:

C#
Private Sub dashboardViewer1_DashboardItemControlUpdated(sender As System.Object, e As DevExpress.DashboardWin.DashboardItemControlEventArgs) Handles dashboardViewer1.DashboardItemControlUpdated If e.DashboardItemName = "gridDashboardItem1" Then Dim gridView = TryCast(e.GridControl.MainView, GridView) For Each column As GridColumn In gridView.Columns column.AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far column.AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Far Next End If End Sub

For Web Dashboard use the following code:

ASPx
<script type="text/javascript"> function ItemWidgetCreatedHandle(e) { if (e.ItemName == "gridDashboardItem1") { var grid = e.GetWidget(); for (var i = 0;i< grid.columnCount(); i++) grid.columnOption(i, 'alignment', 'right'); } } </script> <dx:ASPxDashboardViewer ...> <ClientSideEvents ItemWidgetCreated="function(s,e){ItemWidgetCreatedHandle(e);}" /> </dx:ASPxDashboardViewer>
    Comments (3)

      yes, for viewer too!

      DevExpress Support Team 10 years ago

        Give me some additional time to prepare a sample project for web dashboard.

        DevExpress Support Team 10 years ago

          I have updated my answer.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.