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

RadGrid rendering extremely slow. GridTemplateColumn with RadNumericTextBox

2 Answers 219 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Craig Hauzie
Top achievements
Rank 1
Craig Hauzie asked on 05 Apr 2012, 02:42 PM
I have a very simple grid with 10+ columns. I first started noticing the slowness on rendering (5 to 6 seconds) when there was roughly 125 rows being bound from the database. The slowness I was getting just felt like something was hanging on the client side. Then I started getting the dreaded "a script is still running. do you want to stop or continue?"

I started removing client side features and still was having the same results. Finally I removed the 3 GridTemplateColumns that contained RadNumericTextBoxes and the page rendered instantly. No delay, no nothing. So then I put in regular old asp:TextBox(es) and again, the page rendered instantly.

What gives? Doesn't seem right that using RadNumericTextBoxes inside a RadGrid would cause that much delay. Is there a trick to doing this?

Thanks!

<telerik:RadGrid ID="gvSelectTransactionsEstimated" runat="server" AllowMultiRowSelection="true" AllowSorting="true" EnableEmbeddedSkins="false" OnItemDataBound="gvSelectTransactionsEstimated_ItemDataBound" OnPreRender="gvSelectTransactionsEstimated_PreRender" Skin="VistaCustom">
    <ClientSettings EnableRowHoverStyle="true">
        <Selecting AllowRowSelect="true" UseClientSelectColumnOnly="true" />
    </ClientSettings>
    <MasterTableView ClientDataKeyNames="PremiumRate,PaymentRate" DataKeyNames="PremiumRate,PaymentRate" HierarchyLoadMode="ServerBind" AutoGenerateColumns="false" Name="ParentView" ShowHeader="true">
        <Columns>
            <telerik:GridClientSelectColumn HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" UniqueName="Checkbox"></telerik:GridClientSelectColumn>
            <telerik:GridBoundColumn DataField="PolicyNo" HeaderText="Policy No" SortExpression="PolicyNo" UniqueName="PolicyNo"></telerik:GridBoundColumn>
            <telerik:GridTemplateColumn HeaderText="Collateral Terms" UniqueName="Collateral" SortExpression="CollateralTypeName">
                <ItemTemplate>
                    <asp:Label ID="lblCollateral" runat="server" Text=""></asp:Label>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridDateTimeColumn DataField="PeriodDate" DataFormatString="{0:MM/dd/yyyy}" HeaderText="Period Date" SortExpression="PeriodDate" UniqueName="PeriodDate" ></telerik:GridDateTimeColumn>
            <telerik:GridNumericColumn DataField="ReconcileAmount" DataFormatString="{0:C2}" HeaderText="Prem Due" UniqueName="PremiumDue" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right"></telerik:GridNumericColumn>
            <telerik:GridTemplateColumn HeaderText="Prem Recv" UniqueName="PremiumReceived" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right">
                <ItemTemplate>
                    <telerik:RadNumericTextBox ID="txtPremiumReceived" runat="server" EnabledStyle-HorizontalAlign="Right" Width="61"></telerik:RadNumericTextBox>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="Comm W/h" UniqueName="Commission" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right">
                <ItemTemplate>
                    <telerik:RadNumericTextBox ID="txtCommissionWithheld" runat="server" EnabledStyle-HorizontalAlign="Right" Width="61"></telerik:RadNumericTextBox>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="# Loans" UniqueName="NumberOfLoans" HeaderStyle-HorizontalAlign="Right" ItemStyle-HorizontalAlign="Right">
                <ItemTemplate>
                    <telerik:RadNumericTextBox ID="txtNumberOfLoans" runat="server" EnabledStyle-HorizontalAlign="Right" NumberFormat-DecimalDigits="0" Width="46"></telerik:RadNumericTextBox>
                </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridBoundColumn DataField="CollateralTypeName" UniqueName="CollateralTypeName" Visible="false"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="MaximumFinanceTerm" UniqueName="MaximumFinanceTerm" Visible="false"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="MaximumFinanceAmount" UniqueName="MaximumFinanceAmount" Visible="false"></telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

2 Answers, 1 is accepted

Sort by
0
Elliott
Top achievements
Rank 2
answered on 06 Apr 2012, 07:29 PM
you really don't need numeric text boxes in the ItemTemplate, do you?  Labels will work nicely
what you need the numeric textboxes for is EditItemTemplates, which only get created when a row is edited (or new record added)
I do this all the time:

<telerik:GridTemplateColumn UniqueName="CashBack" HeaderText="CashBack" >
    <ItemTemplate>
        <asp:Label ID="lblCashBack" Text='<%# Bind("CashBack") %>' runat="server" />
    </ItemTemplate>
    <EditItemTemplate>
        <telerik:RadNumericTextBox ID="rntbCashBack" text='<%# Eval("CashBack") %>' runat="server">
            <NumberFormat DecimalDigits="2" />
        </telerik:RadNumericTextBox>
        <asp:RequiredFieldValidator ID="rfvCashBack" ControlToValidate="rntbCashBack" ErrorMessage="Required" runat="server" />
    </EditItemTemplate>
</telerik:GridTemplateColumn>
0
Craig Hauzie
Top achievements
Rank 1
answered on 06 Apr 2012, 08:01 PM
That's actually a good point and that's probably the answer here BUT for the requirements of this page, we do need text boxes in the default state of the grid. I suppose I could just put the grid in EDIT mode full time but I doubt that would even solve the problem as the RadNumericTextBox(es) appear useless within a RadGrid because of the rendering times.

I switched to asp:TextBox(es) and the app is flying now.
Tags
Grid
Asked by
Craig Hauzie
Top achievements
Rank 1
Answers by
Elliott
Top achievements
Rank 2
Craig Hauzie
Top achievements
Rank 1
Share this question
or