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

Access to Columns in RadGrid

3 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Layo
Top achievements
Rank 1
Layo asked on 24 Oct 2012, 07:27 PM
Hi.
How I can access columns in a radgrid by javascript?
I need to change their width upon him by this method.

This are the columns.
 <Columns>
                    <radG:GridBoundColumn SortExpression="region_id" HeaderText="Region" HeaderButtonType="TextButton"
                        DataField="region_id">
                    </radG:GridBoundColumn>
                    <radG:GridBoundColumn SortExpression="qty" HeaderText="Qty" HeaderButtonType="TextButton"
                        DataField="qty">
                    </radG:GridBoundColumn>
                    <radG:GridBoundColumn SortExpression="status" HeaderText="Status" HeaderButtonType="TextButton"
                        DataField="status">
                    </radG:GridBoundColumn>
                  
                </Columns>

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 25 Oct 2012, 05:22 AM
Hi,

Try the following javascript to change the column width from client side.
JS:
function changeWidth() {
    var grid = $find("<%=RadGrid1.ClientID %>");
    var MasterTable = grid.get_masterTableView();
    MasterTable.getColumnByUniqueName("UniqueName").get_element().width = "500px";
    return false;
}

Thanks,
Princy.
0
Layo
Top achievements
Rank 1
answered on 25 Oct 2012, 03:19 PM
hello.
One question, Where do you call that function?.
I'm a little new to this.
thanks
0
Princy
Top achievements
Rank 2
answered on 26 Oct 2012, 03:41 AM
Hi Layo,

I tried to change the width on a button click event as follows.

ASPX:
<asp:Button ID="Button1" runat="server" Text="Resize" OnClientClick="changeWidth()" />

Thanks,
Princy.
Tags
Grid
Asked by
Layo
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Layo
Top achievements
Rank 1
Share this question
or