NeedDataSource and DetailTableDataBind not firing

9 posts, 1 answers
  1. Robert
    Robert avatar
    6 posts
    Member since:
    Apr 2015

    Posted 22 Apr 2015 Link to this post

    I'm having an issue getting my detail table to load properly using NeedDataSource and DetailTableDataBind events.  Stepping through the code shows the neither event is firing.  If I bind the grid to a datasource in my code, the master table will load, however after clicking to expand the row, the DetailTableDataBind does NOT fire.

    I am using ASP.NET 4.5 and Internet Explorer 11.

    Any ideas what I am doing wrong?

    Here is the ajax manager and grid on the aspx page:

        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
          <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="gvwFunds">
              <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="gvwFunds"></telerik:AjaxUpdatedControl>
              </UpdatedControls>
            </telerik:AjaxSetting>
          </AjaxSettings>
        </telerik:RadAjaxManager>
        <div style="width: 600px">
          <telerik:RadGrid ID="gvwFunds" ShowStatusBar="true" runat="server" AutoGenerateColumns="False" PageSize="7"
            AllowSorting="True" AllowMultiRowSelection="False" AllowPaging="True">
            <PagerStyle Mode="NumericPages"></PagerStyle>
            <MasterTableView DataKeyNames="Programs_UID" AllowMultiColumnSorting="True">
              <DetailTables>
                <telerik:GridTableView DataKeyNames="Funds_UID" Width="100%" runat="server">
                  <Columns>
                    <telerik:GridBoundColumn SortExpression="FiscalCode" HeaderText="Fiscal Code" HeaderButtonType="TextButton"
                      DataField="FiscalCode" UniqueName="FiscalCode">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="Fund" HeaderText="Fund" HeaderButtonType="TextButton"
                      DataField="Fund" UniqueName="Fund">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="ObjectCode" HeaderText="Object Code" HeaderButtonType="TextButton"
                      DataField="ObjectCode" UniqueName="ObjectCode">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="Amount" HeaderText="Amount" HeaderButtonType="TextButton"
                      DataField="Amount" UniqueName="Amount" DataFormatString="{0:D}">
                    </telerik:GridBoundColumn>
                  </Columns>
                </telerik:GridTableView>
              </DetailTables>
              <Columns>
                <telerik:GridBoundColumn SortExpression="Program" HeaderText="Program" HeaderButtonType="TextButton"
                  DataField="Program" UniqueName="Program">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn SortExpression="LicenseNum" HeaderText="License #" HeaderButtonType="TextButton"
                  DataField="LicenseNum" UniqueName="LicenseNum">
                </telerik:GridBoundColumn>
              </Columns>
            </MasterTableView>
          </telerik:RadGrid>

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 27 Apr 2015 Link to this post

    Hello Robert,

    In the provided code snippet there are no handlers attached to the OnNeedDataSource and OnDetailTableDataBind events. Can you please ensure that you are attaching the handlers in the code-behind?

    For your convenience, following is a very basic example with your scenario and attached handlers:
    <telerik:RadGrid runat="server" ID="RadGrid1" OnNeedDataSource="RadGrid1_NeedDataSource" OnDetailTableDataBind="RadGrid1_DetailTableDataBind">
        <MasterTableView>
            <DetailTables>
                <telerik:GridTableView Name="DetailTable1"></telerik:GridTableView>
            </DetailTables>
        </MasterTableView>
    </telerik:RadGrid>

    And the code-behind:
    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        DataTable table = new DataTable();
        table.Columns.Add("ID", typeof(int));
        for (int i = 0; i < 2; i++) table.Rows.Add(i);
        (sender as RadGrid).DataSource = table;
    }
     
    protected void RadGrid1_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
    {
        DataTable table = new DataTable();
        table.Columns.Add("NestedValue", typeof(string));
        for (int i = 0; i < 2; i++) table.Rows.Add("NestedValue" + i);
        (sender as RadGrid).DataSource = table;
    }

    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. Robert
    Robert avatar
    6 posts
    Member since:
    Apr 2015

    Posted 27 Apr 2015 in reply to Konstantin Dikov Link to this post

    Kanstantin, thank you for response.

     

    I do indeed attach the handlers in the code behind:

    Protected Sub gvwFunds_DetailTableDataBind(sender As Object, e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles gvwFunds.DetailTableDataBind
    Dim oItem As Telerik.Web.UI.GridDataItem = TryCast(e.DetailTableView.ParentItem, Telerik.Web.UI.GridDataItem)
    e.DetailTableView.DataSource = GetChildGridData(Convert.ToInt32(oItem("Programs_UID").Text))
    End Sub

    Protected Sub gvwFunds_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles gvwFunds.NeedDataSource
    gvwFunds.DataSource = GetParentGridData()
    End Sub

     I do not have any other code that references this grid.  I have a script manager placed on the master page.  I am at my wits end.  I used one of the demos as the basis for this page.  I know it is probably something really simple that I am doing wrong, but I can't figure it out.

     

  4. Robert
    Robert avatar
    6 posts
    Member since:
    Apr 2015

    Posted 27 Apr 2015 Link to this post

    I have found the two culprits.  First, I had to remove the radgrid from the panel that I had it in.  Then the master table would load.  Second, I had to remove the reference to the radgrid from the ajax manager.  Then the detail grid would load and expand.

     

    This ,however, has created a new problem.  I am getting an error when the detail grid loads and expands.  I have attached a screen-shot of the error.

     

     

  5. Answer
    Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 30 Apr 2015 Link to this post

    Hi Robert,

    Please take a look at the following sticky thread regarding the error that you are receiving:
    As you will notice, you need to disable the BrowserLink by adding the following in your web.config file:
    <appsettings>
        <add key="vs:EnableBrowserLink" value="false"></add>
    </appsettings>


    Best Regards,
    Konstantin Dikov
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  6. JeffSM
    JeffSM avatar
    42 posts
    Member since:
    May 2014

    Posted 02 Nov 2018 in reply to Robert Link to this post

    I did this and yet do not expand.
  7. Vessy
    Admin
    Vessy avatar
    2067 posts

    Posted 05 Nov 2018 Link to this post

    Hi JeffSM,

    Can you verify that there are no any Javascript errors thrown on the page when the problem occurs? If no, it will be really helpful if you send your setup so we can reproduce the issue and debug the cause for it.

    Regards,
    Vessy
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  8. JeffSM
    JeffSM avatar
    42 posts
    Member since:
    May 2014

    Posted 05 Nov 2018 in reply to Vessy Link to this post

    I make work configuring via the RadGrid Manager on IDE and using Google Chrome, on IE do not works.
  9. Vessy
    Admin
    Vessy avatar
    2067 posts

    Posted 05 Nov 2018 Link to this post

    Hi JeffSM,

    Please, make sure that IE is not running in compatibility mode as it is not supported and can break the functionality of the control. You can force the use of the latest IE version by adding the following setting to the web.config:
    <system.webServer>
        <httpProtocol>
          <customHeaders>
            <add name="X-UA-Compatible" value="IE=Edge"/>
          </customHeaders>
        </httpProtocol>
    </system.webServer>


    Regards,
    Vessy
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top