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

AJAX-ed RadGrid Expand/Collapse not working

2 Answers 135 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 07 Aug 2013, 02:22 AM
I have two pages named WorkingExpand.aspx and NotWorkingExpand.aspx. Both pages have this declaration:

            <telerik:RadGrid ID="rgRequirements" runat="server" Width="100px" CellSpacing="0" GridLines="None" EnableEmbeddedSkins="True" Skin="Black" >
                <MasterTableView AutoGenerateColumns="False">
                    <NoRecordsTemplate>
                        <asp:Label ID="nocourses" runat="server" Font-Size="16px" Text="No courses are currently selected for this organization."></asp:Label>
                    </NoRecordsTemplate>
                    <Columns>
                        <telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Center" >
<!-- Some Column Definition -->
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>

For WorkingExpand.aspx codebehind, I have this declaration on the Load method:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then
        ' Some code omitted.
        fill_requirements()
    end if           
End Sub
 
Sub fill_requirements()
    Dim dt As DataTable = New DataTable
    dt = ThisMethodReallyReturnsData()
        Me.rgRequirements.DataSource = dt
 
    'Grouping declared here
    Me.rgRequirements.GroupingEnabled = True
    Dim groupExpression As GridGroupByExpression = GridGroupByExpression.Parse("Module Group By Module")
    Me.rgRequirements.MasterTableView.GroupByExpressions.Add(groupExpression)
    Me.rgRequirements.DataBind()
     
End Sub

So notice that the binding to the grid was called on the page load method. There was no need to use advanced databinding to make the expand/collapse work. It just works. 

However for the NotWorkingExpand.aspx code behind, here is how the data is bind:

   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'No related code
   End Sub
 
   Protected Sub rgRequirements_NeedDataSource(ByVal source As System.Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs)
       LoadGrid()
   End Sub
 
   Protected Sub LoadGrid()
       ' dtRequirements is a global variable
       dtRequirements = MethodThatHasDataAsWell()
       Me.rgRequirements.DataSource = dtRequirements
 
       Me.rgRequirements.GroupingEnabled = True
       Dim groupExpression As GridGroupByExpression = GridGroupByExpression.Parse("Module Group By Module")
       Me.rgRequirements.MasterTableView.GroupByExpressions.Add(groupExpression)
   End Sub

When the collapse/expand button is selected, it throws an error


Unhandled exception at line 6, column 74203 in http://localhost:30710/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_ContentContent_rsmTrainingRequirements_TSM&compress=1&_TSM_CombinedScripts_=;;System.Web.Extensions,+Version=4.0.0.0,+Culture=neutral,+PublicKeyToken=31bf3856ad364e35:en-US:c9cbdec3-c810-4e87-846c-fb25a7c08002:ea597d4b:b25378d2;Telerik.Web.UI,+Version=2013.2.611.40,+Culture=neutral,+PublicKeyToken=121fae78165ba3d4:en-US:8a277cf4-155d-4ba9-b3c0-d6f62646e5f2:16e4e7cd:ed16cbdc:f7645509:58366029
 
0x800a138f - Microsoft JScript runtime error: 'undefined' is null or not an object

Any help?

2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 07 Aug 2013, 10:28 AM
Hello,

I am not able to reproduce this issue. I have tried with the below code snippet. Can you please try with the below code snippet?

<telerik:RadGrid ID="RadGrid1" runat="server" Width="100px" CellSpacing="0" OnNeedDataSource="RadGrid1_NeedDataSource"
        AutoGenerateColumns="False">
        <MasterTableView>
            <NoRecordsTemplate>
                <asp:Label ID="nocourses" runat="server" Font-Size="16px" Text="No courses are currently selected for this organization."></asp:Label>
            </NoRecordsTemplate>
            <Columns>
                <telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Center">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("ID") %>'></asp:Label>
                        <asp:Label ID="Label2" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
   {
       GridGroupByExpression groupExpression = GridGroupByExpression.Parse("Name Group By Name");
       RadGrid1.MasterTableView.GroupByExpressions.Add(groupExpression);
 
       dynamic data1 = new[] {
              new { ID = 1, Name ="Name_1"},
              new { ID = 2, Name = "Name_2"},
              new { ID = 3, Name = "Name_1"},
              new { ID = 4, Name = "Name_4"},
              new { ID = 5, Name = "Name_1"}
          };
 
       RadGrid1.DataSource = data1;
 
   }


Thanks,
Jayesh Goyani
0
Patrick
Top achievements
Rank 1
answered on 08 Aug 2013, 01:54 AM
Hi, 

Thanks for the reply but technically it is the same. If you would look at my code snippet, you just moved the contents of the LoadGrid to the needs_datasource event which is technically the same. 

Still, not working. 
Tags
Grid
Asked by
Patrick
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Patrick
Top achievements
Rank 1
Share this question
or