Hi,
We are using v11.2 and are trying to align data of a certain specific columns to right and checkbox to center. We ahve tried below mentioned code approaches but not working. We are generating columns from code-behind. Please help us how to set data to right side of a cell and checkboxes to center of cell.
1st approach
dim cckFld as new BoundCheckBoxField()
cckFld.cssClass= "alignRight"
<style>
.alignRight{ text-align:right}
</style>
2nd approach
protected Sub RowInit(......)
e.Row.Items.Item(ColumnNumber).Column.cssClass="alignRight"
End Sub
Hi Shadow,
Try updating your CSS class definition to align your column right to this:
.alignRight{
text-align:right !important;
}
And to align your checkboxes to the center:
.alignCenter{
text-align:center !important;
The reason you aren't seeing the columns content align to the right or the center is due to the grid on render applying a style with higher specificity on that sets the text-align property to left. By setting the important tag, the text-align property will always be set to what is found with the !important tag regardless of specificity. You can read up on specificity here: https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity
Also, I recommend referencing your CSS classes from your markup. You can do so by setting the CssClass attribute of the BoundDataField/BoundCheckBoxField element equal to your CSS class. The markup will look like this:
<ig:BoundCheckBoxField DataFieldName="Discontinued" Key="Discontinued" CssClass="alignCenter"> <Header Text="Discontinued"></Header></ig:BoundCheckBoxField>
I'm attaching a sample I used to test this behavior.
Let me know if you have any questions.