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

[Solved] Columns don't keep their size after postback with EnablePostBackOnRowClick=true

2 Answers 193 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael Melloff
Top achievements
Rank 2
Michael Melloff asked on 11 Jan 2010, 05:19 PM
Hi

If I resize a column and then click on a row, the postback occurs but the column new size is lost.

Can you please help me with this issue.

Thank you
Michael

ASPX
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title></title
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" /> 
</head> 
<body> 
    <form id="form1" runat="server"
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
        <Scripts> 
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> 
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> 
        </Scripts> 
    </telerik:RadScriptManager> 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="RadGrid1"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server"
    </telerik:RadSkinManager> 
    <div> 
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowMultiRowEdit="True" AllowMultiRowSelection="True" 
            AllowPaging="True" GridLines="None"
            <MasterTableView> 
                <RowIndicatorColumn> 
                    <HeaderStyle Width="20px"></HeaderStyle> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn> 
                    <HeaderStyle Width="20px"></HeaderStyle> 
                </ExpandCollapseColumn> 
            </MasterTableView> 
            <ClientSettings EnablePostBackOnRowClick="True"
                <Selecting AllowRowSelect="True" /> 
                <Resizing AllowColumnResize="True" /> 
            </ClientSettings> 
        </telerik:RadGrid> 
    </div> 
    </form> 
</body> 
</html> 
 

VB
Imports Telerik.Web.UI 
 
Partial Class _Default 
    Inherits System.Web.UI.Page 
 
    Protected Sub RadGrid1_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource 
        Dim DT As New Data.DataTable 
        DT.Columns.Add("ID"
        DT.Columns.Add("Value"
        DT.Rows.Add(New Object() {1, "test1"}) 
        DT.Rows.Add(New Object() {2, "test2"}) 
        DT.Rows.Add(New Object() {3, "test3"}) 
        DT.Rows.Add(New Object() {4, "test4"}) 
 
        RadGrid1.DataSource = DT 
    End Sub 
 
End Class 

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Jan 2010, 07:13 AM
Hello Michael,

Inorder to save the resize settings for a column in the Grid, you may have to hook the OnColumnResized client event, fire an ajax request from the event , pass the new width value of the column to the server side and store it using custom logic to recover the settings later. You can refer to the following forum link, which discusses on the same scenario:
Can we save the clientSettings in RadGrid?

Hope this helps..
Princy.
0
Michael Melloff
Top achievements
Rank 2
answered on 12 Jan 2010, 09:02 AM
Hi Princy

Thanks for the answer but there is a bug here,
I don't wan't to save the state of column for the new login of the user, I want the row click event to be a normal postback.
If you put a button on the page and click it, the grid just updates fine and retains the column width value.

I really need help on this.
Is there a hotfix I could download somewhere?

Michael
Tags
Grid
Asked by
Michael Melloff
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Michael Melloff
Top achievements
Rank 2
Share this question
or