MVC Grid Column content align

0 Answers 88 Views
Grid
Cristian
Top achievements
Rank 1
Iron
Cristian asked on 20 Sep 2022, 12:54 PM

Hi all

In my grid k-text-center and k-text-right are not working.

This is the column definition:

cols.Bound(c => c.id).Title("#").HeaderHtmlAttributes(new { @class = "k-text-center !k-justify-content-center" }).HtmlAttributes(new { @class = "k-text-right" });

as per this demo, but i still see the content (both header and column) align on left.

 

If i use .HtmlAttributes(new { style = "text-align: center" }); it works.

 

Checking the class I see the problem is the "text-align: inherit;" of k-grid class

Check the image named "Before":

And the image "After" 

 

BR

Cristian

 

 

Anton Mironov
Telerik team
commented on 23 Sep 2022, 10:40 AM

Hi Cristian,

Thank you for the images, code snippets, and details provided.

In order to ignore the inherent stylings and apply the right position of the content in a column, I would recommend using the following(as in the pointed demo):

  columns.Bound(p => p.ShipName).HeaderHtmlAttributes(new { style = "text-align: center; justify-content: center" })
            .HtmlAttributes(new { style = "text-align: right" });
Give a try to the approach above and let me know if this is the desired result.


Kind Regards,
Anton Mironov

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Cristian
Top achievements
Rank 1
Iron
Share this question
or