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

Combobox Inside Radgrid - Postback speed issue

3 Answers 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan Pope
Top achievements
Rank 1
Ryan Pope asked on 04 Oct 2010, 04:09 PM

Hey,

I currently have a grid that lists  many GridTemplateColumns within it. Three of these columns contain RadComboBoxes in them. The first cascades down to the two below it. When I change the selectedIndex of the first combo box, I trigger a postback which then fills the other two combo boxes with the appropriate values. This is all done without using an edit button, every line is editable when the grid is loaded. When the postback is triggered, it takes the grid a long time even though the code behind the selectedIndexChanged is empty and does not do anything. Do you know how I could do this without using a postback and so it only updates/looks at the line (javascript?), or to speed this postback up? I have attached the code I am using from the grid, and any help would be greatly appreciated.

It appears that when I select one RadComboBox, the postback goes through and touches every Item in teh RadGrid. I figure this because the more items that are returned into the grid, the longer it takes to fill the combo boxes for that line. Is there a way to only look at the line I am currently working on?

Thanks,
Ryan



<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel" runat="server" Skin="Default" InitialDelayTime="500">
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadAjaxPanel ID="RadAjaxPanel" runat="server" LoadingPanelID="RadAjaxLoadingPanel">
            <telerik:RadGrid ID="grdRIExceptions" runat="server" GridLines="None" 
                AutoGenerateColumns="False" Width="100%" AllowPaging="True" PageSize="50" 
                DataSourceID="ExceptionDataSource">
                <GroupingSettings CaseSensitive="False" GroupByFieldsSeparator="&nbsp;&nbsp;&nbsp;" />
                <ClientSettings>
                    <Scrolling ScrollHeight="500px" />
                </ClientSettings>
                <GroupHeaderItemStyle Font-Bold="True" Font-Size="12px" ForeColor="#333333" />
                <MasterTableView NoMasterRecordsText="There are no exceptions in your region with the set filters." 
                    DataKeyNames="CUST_No,STC_Code,INV_PrevDocNo" ClientDataKeyNames="CUST_No" 
                    DataSourceID="ExceptionDataSource" Width="100%">
                    <RowIndicatorColumn>
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn>
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </ExpandCollapseColumn>
                    <CommandItemSettings />
                    <Columns>
                        <telerik:GridBoundColumn DataField="CUST_No" EditFormHeaderTextFormat="{0}&nbsp;:" HeaderText="Customer No" UniqueName="CUST_No" Visible="False">
                            <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" Wrap="True" />
                            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" Wrap="True" />
                        </telerik:GridBoundColumn>
                        <telerik:GridTemplateColumn DataField="CUST_Name" EditFormHeaderTextFormat="{0}&nbsp;:" HeaderText="Cust." SortExpression="CUST_Name" UniqueName="CUST_Info">
                            <ItemTemplate>
                                <asp:LinkButton ID="btnViewCustomerInfo" runat="server">View</asp:LinkButton>
                                <asp:Label ID="lblCustNo" runat="server" Font-Underline="True" Text='<%# Eval("CUST_No") %>' Visible="False"></asp:Label>
                                <asp:Label ID="lblCustName" runat="server" Text='<%# Eval("CUST_Name") %>' Visible="false"></asp:Label>
                                <asp:Label ID="lblCustDisplay" runat="server" Text='<%# Eval("CUST_Name") + "(" + Eval("CUST_No") + ")" %>' Visible="false"></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" Width="30px" Wrap="True" HorizontalAlign="Left" />
                            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" Wrap="True" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn DataField="CUST_Name" HeaderText="Customer" UniqueName="CustomerName" Display="False">
                            <ItemTemplate>
                                <asp:Label ID="lblCustDisplay2" runat="server" Text='<%# Eval("CUST_Name") + "(" + Eval("CUST_No") + ")" %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" Width="275px" Wrap="True" HorizontalAlign="Left" />
                            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" Wrap="True" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Rental Order" UniqueName="NumOfRentalOrders">
                            <ItemTemplate>
                                <asp:Label ID="lblRONo" runat="server" Text='<%# Eval("INV_PrevDocNo") %>'></asp:Label>
                                <asp:Label ID="lblPrevDocType" runat="server" Text='<%# Eval("INV_PrevDocType") %>' Visible="false"></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" Wrap="True" HorizontalAlign="Left" Width="75px" />
                            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" Wrap="True" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn DataField="INV_No" HeaderText="Inv/CM No." UniqueName="column1">
                            <ItemTemplate>
                                <asp:Label ID="lblInvNo" runat="server" Text='<%# Eval("INV_No") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" Wrap="True" Width="75px" />
                            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" Wrap="True" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn DataField="INV_PostDate" HeaderText="Inv/CM Date" UniqueName="column">
                            <ItemTemplate>
                                <asp:Label ID="INV_PostDateLabel" runat="server" Text='<%# Eval("INV_PostDate") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" Wrap="True" Width="75px" />
                            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" Wrap="True" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Ship-to Information" UniqueName="STC_Code" DataField="STC_Code" GroupByExpression="STC_Code" SortExpression="STC_Code">
                            <ItemTemplate>
                                <asp:Label ID="lblSTCCode" runat="server" Text='<%# Eval("STC_Code") %>' Visible="false"></asp:Label>
                                <asp:Label ID="lblSTCName" runat="server" Text='<%# Eval("STC_Name") %>' Visible="false"></asp:Label>
                                <asp:Label ID="lblSTCUnlinked" runat="server" Text='<%# Eval("STC_Unlinked") %>' Visible="false"></asp:Label>
                                <asp:Label ID="lblSTCDisplay" runat="server"></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" Wrap="False" HorizontalAlign="Left" />
                            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" Wrap="False" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn DataField="STC_City" GroupByExpression="STC_City" HeaderText="City" SortExpression="STC_City" UniqueName="STC_City">
                            <ItemTemplate>
                                <asp:Label ID="lblSTCCity" runat="server" Text='<%# Eval("STC_City") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" Wrap="True" Width="100px" />
                            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn DataField="STC_State" GroupByExpression="STC_State" HeaderText="State" SortExpression="STC_State" UniqueName="STC_State">
                            <ItemTemplate>
                                <asp:Label ID="lblSTCState" runat="server" Text='<%# Eval("STC_State") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" Width="28px" Wrap="True" />
                            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" Wrap="True" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn DataField="STC_Zip" GroupByExpression="STC_Zip" HeaderText="Zip Code" SortExpression="STC_Zip" UniqueName="STC_Zip">
                            <ItemTemplate>
                                <asp:Label ID="lblSTCZip" runat="server" Text='<%# Eval("STC_Zip") %>'></asp:Label>
                            </ItemTemplate>
                            <HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" Width="55px" Wrap="True" HorizontalAlign="Right" />
                            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Right" Wrap="True" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Fix Type" UniqueName="FixType">
                            <ItemTemplate>
                                <telerik:RadComboBox ID="cboExceptionFixType" Runat="server" Width="125px" AutoPostBack="True" MarkFirstMatch="True" OnSelectedIndexChanged="cboExceptionFixType_SelectedIndexChanged" DropDownWidth="175px">
                                    <Items>
                                        <telerik:RadComboBoxItem runat="server" Selected="True" Text="Skip" Value="Select" />
                                        <telerik:RadComboBoxItem runat="server" Text="Always on this Address" Value="STC" />
                                        <telerik:RadComboBoxItem runat="server" Text="This Contract Only" Value="RO" />
                                    </Items>
                                </telerik:RadComboBox>
                                <asp:CheckBox ID="chkFixed" runat="server" Visible="False" />
                            </ItemTemplate>
                            <HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" Wrap="False" Width="120px" />
                            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" Wrap="False" />
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Assign Salesperson / Branch" UniqueName="AssignSP">
                            <ItemTemplate>
                                <telerik:RadComboBox ID="cboExceptionSalesperson" runat="server" Width="125px" DropDownWidth="175px" Height="400px" Enabled="False"  AutoPostBack="True" MarkFirstMatch="True" DataTextField="SP_Name" DataValueField="SP_Code" OnSelectedIndexChanged="cboExceptionSalesperson_SelectedIndexChanged">
                                    <Items>
                                        <telerik:RadComboBoxItem runat="server" Selected="True" Text="Select Salesperson" Value="" />
                                    </Items>
                                </telerik:RadComboBox>
                                   
                                <telerik:RadComboBox ID="cboExceptionBranch" runat="server" AutoPostBack="False" Width="125px" DropDownWidth="175px" MarkFirstMatch="True" Enabled="False" DataTextField="Code" DataValueField="Code">
                                    <Items>
                                        <telerik:RadComboBoxItem runat="server" Selected="True" Text="Select Branch" Value="" />
                                    </Items>
                                </telerik:RadComboBox>
                            </ItemTemplate>
                            <HeaderStyle Font-Bold="True" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" Wrap="False" Width="315px" />
                            <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False" Font-Underline="False" HorizontalAlign="Left" Wrap="False" />
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>

3 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 07 Oct 2010, 12:32 PM
Hi Ryan,

Indeed, when you perform postback from the RadComboBox, the whole grid is recreated and re-rendered. To overcome this issue, I would suggest that you load your comboboxes on demand instead of using the SelectedIndexChanged event. You can find more information here.

Additionally, I observed you have another thread open on the same subject. To avoid duplicate posting, I suggest that we continue the discussion in one of them.

Sincerely yours,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ryan Pope
Top achievements
Rank 1
answered on 07 Oct 2010, 02:17 PM
Thank you for your response!
What I need to know now is using the item_requested method, how do I get the values from the line I am on. I need to be able to get the Zip, State & City from the line of the grid I am currently working on. How do I access the values from the Grid that I need for this method. Or is one of the other methods able to look and get these values without creating a postback?

Protected Sub RadComboBox2_ItemsRequested(ByVal sender As Object, ByVal e As RadComboBoxItemsRequestedEventArgs)
            Dim data As DataTable = GetData(e.Text)
  
            Dim itemOffset As Integer = e.NumberOfItems
            Dim endOffset As Integer = Math.Min(itemOffset + ItemsPerRequest, data.Rows.Count)
            e.EndOfItems = endOffset = data.Rows.Count
  
            For i As Integer = itemOffset To endOffset - 1
                RadComboBox2.Items.Add(New RadComboBoxItem(data.Rows(i)("CompanyName").ToString(), data.Rows(i)("CompanyName").ToString()))
            Next
  
            e.Message = GetStatusMessage(endOffset, data.Rows.Count)
        End Sub
  
    Private Shared Function GetData(ByVal text As String) As DataTable
        Dim dt As New DataTable
        Dim strConnection As String = ConfigurationManager.ConnectionStrings("RDAConnectionString").ToString
  
        Dim connection As SqlConnection = New SqlConnection(strConnection)
        connection.Open()
        Try
            Dim command As SqlCommand = New SqlCommand("pr_ARCPortal_Find_Salespeople_For_Exception", connection)
            command.CommandType = CommandType.StoredProcedure
            command.CommandTimeout = 0
  
            command.Parameters.AddWithValue("@Company", Session("ARCPortal_Company"))
            command.Parameters.AddWithValue("@RC", lblRegionalCompany.Text)
            command.Parameters.AddWithValue("@Zip", item("STC_Zip").Text)
            command.Parameters.AddWithValue("@City", item("STC_City").Text)
            command.Parameters.AddWithValue("@State", item("STC_State").Text)
  
            Dim adapter As SqlDataAdapter = New SqlDataAdapter(command)
            adapter.Fill(dt)
        Catch ex As Exception
        Finally
            connection.Close()
        End Try
  
        Return dt
    End Function
0
Iana Tsolova
Telerik team
answered on 07 Oct 2010, 03:30 PM
Hello Ryan,

In the ItemsRequest event handler, the sender argument is the RadComboBox and its NamingContainer should be the current grid item. From then on, you can review the this article for more infoamtion on how to access grid cells and rows and their controls.

Best wishes,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Ryan Pope
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Ryan Pope
Top achievements
Rank 1
Share this question
or