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

NeedDataSource and DetailTableDataBind not firing

8 Answers 418 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 22 Apr 2015, 09:42 PM

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>

8 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 27 Apr 2015, 11:39 AM
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.

 
0
Robert
Top achievements
Rank 1
answered on 27 Apr 2015, 01:56 PM

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.

 

0
Robert
Top achievements
Rank 1
answered on 27 Apr 2015, 06:25 PM

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.

 

 

0
Accepted
Konstantin Dikov
Telerik team
answered on 30 Apr 2015, 07:09 AM
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.

 
0
JeffSM
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 02 Nov 2018, 01:20 PM
I did this and yet do not expand.
0
Vessy
Telerik team
answered on 05 Nov 2018, 02:19 PM
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.
0
JeffSM
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 05 Nov 2018, 02:25 PM
I make work configuring via the RadGrid Manager on IDE and using Google Chrome, on IE do not works.
0
Vessy
Telerik team
answered on 05 Nov 2018, 03:00 PM
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.
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Robert
Top achievements
Rank 1
JeffSM
Top achievements
Rank 2
Iron
Veteran
Iron
Vessy
Telerik team
Share this question
or