From df9ab39a58582284218e98098607a60128e0f161 Mon Sep 17 00:00:00 2001 From: Dimo Dimov Date: Fri, 10 Sep 2021 17:32:34 +0300 Subject: [PATCH 1/3] Add Grid right align header cells KB --- .../grid-right-align-header-cells.md | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 knowledge-base/grid-right-align-header-cells.md diff --git a/knowledge-base/grid-right-align-header-cells.md b/knowledge-base/grid-right-align-header-cells.md new file mode 100644 index 0000000000..ae69b5d72c --- /dev/null +++ b/knowledge-base/grid-right-align-header-cells.md @@ -0,0 +1,95 @@ +--- +title: Right Align Grid Header Cells +description: How to align the text in Grid header and data cells to the right +type: how-to +page_title: Right Align Grid Header Cells +slug: grid-kb-right-align-header-cells +position: +tags: grid, header, headers, right, align, text-align +ticketid: +res_type: kb +--- + +## Description + +I have a Grid that displays numeric data. The numbers in the data cells are aligned to the right with the `TextAlign` column attribute. How do I align the text content of Grid header cells to the right? + +## Solution + +To align the Grid header cell labels to the right, use custom CSS as per the example below. Note that different CSS rules are needed, depending on the Grid configuration. The CSS code affects all columns. + +>caption Align Grid header cells and data cells to the right + +````CSHTML + + + + + + + + + + +@code { + public List GridData { get; set; } + + protected override void OnInitialized() + { + GridData = new List(); + var rnd = new Random(); + + for (int i = 1; i <= 5; i++) + { + + GridData.Add(new Product() + { + ID = i, + Name = "Product " + i.ToString(), + Price = (decimal)rnd.Next(1, 100), + Quantity = (short)rnd.Next(1, 100) + }); + } + } + + public class Product + { + public int ID { get; set; } + public string Name { get; set; } + public decimal Price { get; set; } + public short Quantity { get; set; } + } +} +```` From f28deff80c87c48f8f51c16711a0f18eb15d5bd9 Mon Sep 17 00:00:00 2001 From: Dimo Dimov Date: Mon, 13 Sep 2021 17:05:26 +0300 Subject: [PATCH 2/3] Refactor CSS rules --- knowledge-base/grid-right-align-header-cells.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/knowledge-base/grid-right-align-header-cells.md b/knowledge-base/grid-right-align-header-cells.md index ae69b5d72c..ad8c2bea36 100644 --- a/knowledge-base/grid-right-align-header-cells.md +++ b/knowledge-base/grid-right-align-header-cells.md @@ -33,15 +33,14 @@ To align the Grid header cell labels to the right, use custom CSS as per the exa