How to right-align RadGridView Summary Row Item using the designer property

1 Answer 381 Views
GridView
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
Gone2TheDogs asked on 10 Aug 2022, 03:29 PM
I have a GridViewSummaryItem for Total, but it aligns to the center while the data rows align to the right. How do I get the summary Item to align right? I created the summary row and item using the designer (see attached screenshot).
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
commented on 10 Aug 2022, 04:22 PM

I couldn't figure out how to do it from the designer, but from another thread, I used the cellformatting event. If anyone knows how to format from the designer property, please post! Thanks!

 


		private void dgvPOItems_ViewCellFormatting(object sender, CellFormattingEventArgs e)
		{
			if (e.CellElement is Telerik.WinControls.UI.GridSummaryCellElement)
			{
				e.CellElement.TextAlignment = ContentAlignment.MiddleRight;
			}
		}

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 11 Aug 2022, 08:11 AM

Hello, Bob,

Due to the UI virtualization in RadGridView, cell elements are created only for currently visible cells and are being reused during operations like scrolling, filtering, grouping and so on. That is why the control offers the CellFormatting/ViewCellFormatting events which are purposed to customize the cell elements according to your requirements. It is not possible to specify the text alignment for the summary items at design time. You should do it programmatically.

In order to prevent applying the formatting to other columns' cell elements (because of the cell reuse), all customization should be reset for the rest of the cell elements.  

        private void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
        {
            GridSummaryCellElement summaryCell = e.CellElement as GridSummaryCellElement;
            if (summaryCell != null)
            {
                e.CellElement.TextAlignment = ContentAlignment.MiddleLeft;
            }
            else
            { 
                e.CellElement.ResetValue(LightVisualElement.TextAlignmentProperty, ValueResetFlags.Local);
            }
        }

I hope this information helps. If you need any further assistance please don't hesitate to contact me.

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
GridView
Asked by
Gone2TheDogs
Top achievements
Rank 1
Iron
Veteran
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or