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

sender.get_masterTableView() returns null in GridDestroying after .NET 4.0 upgrade

2 Answers 179 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Attila
Top achievements
Rank 1
Attila asked on 18 Jul 2011, 12:41 PM
I have a RadGrid (along with a RadAjaxManager). The version is 2010.1.415.35

There is a 'Refresh' button on the page, which eventually calls __doPostBack.
Everything was working fine until I upgraded the website from .NET 3.5 to 4.0.
But now, after the AJAX call sender.get_masterTableView() returns null in the GridDestroying function.

Is there a fix for this version?

Attila
 
<telerik:RadGrid 
            ID="grid"
            CellPadding="1"
            CellSpacing="0"
            EnableEmbeddedSkins="false"
            AlternatingItemStyle-Height="20"
            ItemStyle-Height="20"
            ShowFooter="True"
            AllowSorting="False"            
            runat="server"
            EnableEmbeddedBaseStylesheet="false"
            AutoGenerateColumns="false"
            AllowMultiRowEdit="true"
            GridLines="None"
            Width="100%"            
            ExportSettings-FileName="Summary"
            ExportSettings-Excel-FileExtension="xls"
            ExportSettings-Excel-Format="HTML"
            ExportSettings-OpenInNewWindow="true"
            ExportSettings-ExportOnlyData="true"             
            ExportSettings-IgnorePaging="true">             
            <ClientSettings>
                <Scrolling AllowScroll="True" UseStaticHeaders="true" />
            </ClientSettings>             
            <HeaderContextMenu EnableEmbeddedSkins="False"></HeaderContextMenu>
        <MasterTableView 
                ClientDataKeyNames="ROW_ID"
                DataKeyNames="ROW_ID"
                EditMode="InPlace"
                CommandItemDisplay="Bottom"
                AllowMultiColumnSorting="False"                
               >
            <EditFormSettings>
                <EditColumn InsertImageUrl="Update.gif" UpdateImageUrl="Update.gif" EditImageUrl="Edit.gif"
                    CancelImageUrl="Cancel.gif">
                </EditColumn>
            </EditFormSettings>
                <CommandItemTemplate>
                    <asp:Button ID="btnSave" runat="server" OnClientClick="AddNew();return false;" Text="Add" />  
                </CommandItemTemplate>
            </MasterTableView>
            <ClientSettings>
                <ClientEvents OnRowCreated="RowCreated" OnGridCreated="GridCreated" OnRowClick="RowClick" OnRowContextMenu="showMenu" OnColumnContextMenu="showHeaderMenu" OnCommand="RadGrid1_Command" OnGridDestroying="GridDestroying" />
            </ClientSettings>
        </telerik:RadGrid>

p
rotected override void RaisePostBackEvent( IPostBackEventHandler source, string eventArgument ) {     base.RaisePostBackEvent( source, eventArgument );     if ( source == this. )     {         if ( eventArgument.IndexOf( "Refresh" ) != -1 )         {             grid.Rebind();         }     } }

function GridDestroying(sender, eventArgs) {
    for (var i = 0; i < sender.get_masterTableView().get_dataItems().length; i++) {
        var curRow = sender.get_masterTableView().get_dataItems()[i];
        for (var j = 0; j < curRow.get_element().cells.length; j++) {
            var cell = curRow.get_element().cells[j];
            if (cell) {
                $clearHandlers(cell);
            }
        }
    }
}

2 Answers, 1 is accepted

Sort by
0
Accepted
Martin
Telerik team
answered on 21 Jul 2011, 02:42 PM
Hello Attila,

The problem is that when using AJAX, the mastertableview object is disposed earlier in .NET 4.0 scenarios. I recommend that you try to move this logic to OnTableDestroying event instead.

I hope this helps.

Greetings,
Martin
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Attila
Top achievements
Rank 1
answered on 22 Jul 2011, 12:45 PM
Cells are already disposed in OnTableDestroying, so the appropriate event is OnRowDestroying.

Thanks,
Attila
Tags
Grid
Asked by
Attila
Top achievements
Rank 1
Answers by
Martin
Telerik team
Attila
Top achievements
Rank 1
Share this question
or