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

Ajax postback first time issue

3 Answers 14 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 20 Feb 2018, 06:20 AM

Hi, we're got a RadGrid on a page with a RadAjaxManager and RadAjaxLoadingPanel. On the first operation, using any of the paging, filtering, sorting etc. the grid doesn't appear to be using ajax on postback. Every other operation after that is fine and works as expected. There are no errors on the client or server side. It's a pretty simple page using version 2018.1.117.40. Thanks!

ASPX

<telerik:RadGrid ID="rgDocuments" runat="server" GridLines="None" Skin="MetroTouch" OnNeedDataSource="rgDocuments_NeedDataSource" AllowPaging="True" PageSize="18" AllowFilteringByColumn="True" AllowSorting="True" GroupingSettings-CaseSensitive="false" EnableLinqExpressions="False" RenderMode="Lightweight">
    <MasterTableView AutoGenerateColumns="False" ClientDataKeyNames="docsref" TableLayout="Fixed">
        <Columns>
            <telerik:GridTemplateColumn DataField="docname" HeaderText="Document" SortExpression="docname" UniqueName="docname" HeaderStyle-Width="31%" ItemStyle-Width="31%" ShowFilterIcon="false" FilterControlWidth="400px" AutoPostBackOnFilter="true">
                <ItemTemplate>
                    <span title='<%# Eval("docname") %>'>
                        <%# Eval("docname") %></span>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn DataField="fcName" HeaderText="Area" SortExpression="fcName" UniqueName="fcName" HeaderStyle-Width="15%" HeaderStyle-Wrap="false" ItemStyle-Width="15%" ItemStyle-Wrap="false" ShowFilterIcon="false" AutoPostBackOnFilter="true">
                <FilterTemplate>
                    <telerik:RadComboBox ID="ddlArea" DataSourceID="sdsArea" DataTextField="fcName" DataValueField="fcName" Width="150px" Height="294px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("fcName").CurrentFilterValue %>' runat="server" OnClientSelectedIndexChanged="ddlAreaClientSelectedIndexChanged" Skin="MetroTouch" RenderMode="Lightweight">
                        <Items>
                            <telerik:RadComboBoxItem Text="All" />
                        </Items>
                    </telerik:RadComboBox>
                    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                        <script type="text/javascript">
                            function ddlAreaClientSelectedIndexChanged(sender, args) {
                                var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                tableView.filter("fcName", args.get_item().get_value(), "EqualTo");
                        }
                        </script>
                    </telerik:RadScriptBlock>
                </FilterTemplate>
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="type" HeaderText="Type" SortExpression="type" UniqueName="type" HeaderStyle-Width="15%" HeaderStyle-Wrap="false" ItemStyle-Width="15%" ItemStyle-Wrap="false" ShowFilterIcon="false" AutoPostBackOnFilter="true">
                <FilterTemplate>
                    <telerik:RadComboBox ID="ddlType" DataSourceID="sdsType" DataTextField="type" DataValueField="type" Width="150px" Height="294px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("type").CurrentFilterValue %>' runat="server" OnClientSelectedIndexChanged="ddlTypeClientSelectedIndexChanged" Skin="MetroTouch" RenderMode="Lightweight">
                        <Items>
                            <telerik:RadComboBoxItem Text="All" />
                        </Items>
                    </telerik:RadComboBox>
                    <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
                        <script type="text/javascript">
                            function ddlTypeClientSelectedIndexChanged(sender, args) {
                                var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                tableView.filter("type", args.get_item().get_value(), "EqualTo");
                        }
                        </script>
                    </telerik:RadScriptBlock>
                </FilterTemplate>
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="subtype" HeaderText="Subtype (leg docs)" SortExpression="subtype" UniqueName="subtype" HeaderStyle-Width="15%" HeaderStyle-Wrap="false" ItemStyle-Width="15%" ItemStyle-Wrap="false" ShowFilterIcon="false" AutoPostBackOnFilter="true">
                <FilterTemplate>
                    <telerik:RadComboBox ID="ddlSubtype" DataSourceID="sdsSubtype" DataTextField="subtype" DataValueField="subtype" Width="150px" Height="294px" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("subtype").CurrentFilterValue %>' runat="server" OnClientSelectedIndexChanged="ddlSubtypeClientSelectedIndexChanged" Skin="MetroTouch" RenderMode="Lightweight">
                        <Items>
                            <telerik:RadComboBoxItem Text="All" />
                        </Items>
                    </telerik:RadComboBox>
                    <telerik:RadScriptBlock ID="RadScriptBlock3" runat="server">
                        <script type="text/javascript">
                            function ddlSubtypeClientSelectedIndexChanged(sender, args) {
                                var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                tableView.filter("subtype", args.get_item().get_value(), "EqualTo");
                        }
                        </script>
                    </telerik:RadScriptBlock>
                </FilterTemplate>
            </telerik:GridBoundColumn>
            <telerik:GridDateTimeColumn DataField="reviewDate" HeaderText="Review Date" SortExpression="reviewDate" UniqueName="reviewDate" PickerType="DatePicker"
                DataFormatString="{0:dd/MM/yyyy}" HeaderStyle-Width="12%" HeaderStyle-Wrap="false" ItemStyle-Width="12%" ItemStyle-Wrap="false" AutoPostBackOnFilter="true" DataType="System.DateTime" ShowFilterIcon="false">
            </telerik:GridDateTimeColumn>
            <telerik:GridBoundColumn DataField="docsref" HeaderText="Doc No." SortExpression="docsref" UniqueName="docsref" HeaderStyle-Width="12%" HeaderStyle-Wrap="false" ItemStyle-Width="12%" ItemStyle-Wrap="false" ShowFilterIcon="false" AutoPostBackOnFilter="true">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
    <ClientSettings EnableRowHoverStyle="true">
        <Resizing AllowColumnResize="true" />
        <ClientEvents OnRowClick="rgDocuments_RowClick" />
    </ClientSettings>
</telerik:RadGrid>
<asp:SqlDataSource ID="sdsArea" runat="server" ConnectionString="<%$ ConnectionStrings:IntranetConnectionString %>" SelectCommand="sp_docportal_ddl_area" SelectCommandType="StoredProcedure" CancelSelectOnNullParameter="false">
</asp:SqlDataSource>
<asp:SqlDataSource ID="sdsType" runat="server" ConnectionString="<%$ ConnectionStrings:IntranetConnectionString %>" SelectCommand="sp_docportal_ddl_type" SelectCommandType="StoredProcedure" CancelSelectOnNullParameter="false">
</asp:SqlDataSource>
<asp:SqlDataSource ID="sdsSubtype" runat="server" ConnectionString="<%$ ConnectionStrings:IntranetConnectionString %>" SelectCommand="sp_docportal_ddl_subtype" SelectCommandType="StoredProcedure" CancelSelectOnNullParameter="false">
</asp:SqlDataSource>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnablePageHeadUpdate="false">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="rgDocuments">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="rgDocuments" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>

 

CS

protected void rgDocuments_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    try
    {
        using (connection = new SqlConnection(@"Server=HA-SQL08;UID=*****;PWD=*****;database=intranet"))
        {
            dt = new DataTable();
            connection.Open();
            command = new SqlCommand("v3_docportal", connection);
            command.CommandType = CommandType.StoredProcedure;
            adapter = new SqlDataAdapter(command);
            adapter.Fill(dt);
            rgDocuments.DataSource = dt;
        }
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

 

 

 

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 22 Feb 2018, 09:01 AM
Hi Daniel,

This is strange, indeed. Please ensure once again that there are no hidden script errors by temporarily disabling AJAX:
https://www.telerik.com/support/kb/aspnet-ajax/ajaxmanager/details/get-more-descriptive-errors-by-disabling-ajax

I am sending a very basic runnable RadGrid web site sample. You can add the grid to the AjaxSettings of the manager and verify that it works as expected on your side, too.

Looking forward to hearing from you.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Daniel
Top achievements
Rank 1
answered on 22 Feb 2018, 11:02 PM

Hi Eyup, thanks for the links. We sort of found the issue. I should have explained in a but more detail. We're running this on SharePoint 2013. We found that when we used the regular ASP UpdatePanel things worked fine so there must have been another UpdatePanel somewhere that wasn't playing nice with the RadAjaxManager.

We did some testing with the RadAjaxManager and attached an OnRequestStart client event and it looks like the first ajax update never gets triggered but all others do. Disabling ajax works but the RadGrid still goes to the next page even when the ajax is broken.

It's a shame as the RadAjaxManager is so much more feature rich. We can probably work through this but any other thoughts?

Thanks

Daniel

0
Eyup
Telerik team
answered on 27 Feb 2018, 02:18 PM
Hi Daniel,

After you ensure that everything works perfectly without AJAX, please check the following articles before enabling it back:
http://docs.telerik.com/devtools/aspnet-ajax/sharepoint/troubleshooting/sharepoint-ajax-updates and http://docs.telerik.com/devtools/aspnet-ajax/controls/ajaxmanager/troubleshooting/dynamically-adding-radajaxmanager-to-sharepoint-web-parts

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Daniel
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Daniel
Top achievements
Rank 1
Share this question
or