This is a migrated thread and some comments may be shown as answers.

align a column text to right

1 Answer 24 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alyssa
Top achievements
Rank 1
Alyssa asked on 06 Dec 2013, 01:07 PM
Hello.
How to align a column text to right . I want code in javascript.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 09 Dec 2013, 04:53 AM
Hi Alyssa,

Please try the following code snippet.

ASPX:
<ClientSettings>
 <ClientEvents OnGridCreated="OnGridCreated" />
</ClientSettings>

JS:
<script type="text/javascript">
    function OnGridCreated() {
        var colIndex;
        var grid = $find("<%=RadGrid1.ClientID %>");
        var MasterTable = grid.get_masterTableView();
        var Rows = MasterTable.get_dataItems();
        for (var i = 0; i < Rows.length; i++) {
            var col = Rows[i].get_cell("ColumnUniqueName");
            col.style.textAlign = "right";
            colIndex = col.cellIndex; //to get the cell index
        }
        MasterTable.HeaderRow.cells[colIndex].style.textAlign = "right"; // to align the header text
    }
</script>

Thanks,
Shinu
Tags
Grid
Asked by
Alyssa
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or