I'm sure it's simple, but I'm not figuring it out.
I have a column that I'm formatting as currency. However, all of the text is Left justified in that column. It would be a lot easier to read if all the values lined up and where right justified.
What do I do if I want to right justify a column... or center since we're on the topic.
Hi Tony,
you can use some jQuery code similar to this one below, it will do it. At the moment there isn't a way to do this by setting just a column option in the grid configuration, but it's on the list.
$("#grid1").live("iggridrendered", function (event, args) { // right-justify text in the third column args.owner.element.find("tr td:nth-child(3)").css("text-align", "right"); // or "center" });
In the context of MVC, it could be declared like:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <script type="text/javascript"> $(document).ready(function () { $("#grid1").live("iggridrendered", function (event, args) { // right-justify text in the third column args.owner.element.find("tr td:nth-child(3)").css("text-align", "right"); }); }); </script> <%= Html.Infragistics().Grid(Model).ID("grid1").Height("250px").Columns(column =>
// rest of the grid definition
Hope it helps,
Angel
This script works great, but is there a way to specify the alignment of INDIVIDUAL columns. I see that you can use css to specify the alignment of all columns. Thanks in advance for any advice.
This is regarding column data justification, instead of using css styles to align data, is there any attribute you can specify as column options? as we generate columns and it will be easy if there is just an option to column definitions.
Please let me know.
Thanks
one caveat with this: if you sort the grid by any column, the field goes back to left justification. I'm thinking I'll solve this with the row template and styles though.
Thanks again,Tony
The code worked beautifully!
Thank you!