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

[Solved] Save value in RadNumericTextBox while sorting - how?

1 Answer 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Grzesiek
Top achievements
Rank 2
Iron
Grzesiek asked on 12 Nov 2009, 08:17 PM
I have a Grid:

     <telerik:RadGrid ID="pracownicy" AllowSorting="true" runat="server" GridLines="None" 
         ShowFooter="true" DataMember="employee"
         <MasterTableView> 
             <RowIndicatorColumn> 
                 <HeaderStyle Width="20px"></HeaderStyle> 
             </RowIndicatorColumn> 
             <ExpandCollapseColumn> 
                 <HeaderStyle Width="20px"></HeaderStyle> 
             </ExpandCollapseColumn> 
             <Columns> 
                 <telerik:GridTemplateColumn HeaderText="Gracz" SortExpression="employee_name"
                     <ItemTemplate> 
                         <href='<%# "http://www.erepublik.com/en/citizen/profile/" & Eval("employee_id") %>' 
                             target="_blank"
                             <%#Eval("employee_name")%></a
                     </ItemTemplate> 
                     <ItemStyle HorizontalAlign="Center" Width="200px" /> 
                     <HeaderStyle HorizontalAlign="Center" /> 
                 </telerik:GridTemplateColumn> 
                 <telerik:GridBoundColumn DataField="employee_skill" DataType="System.Double" HeaderText="UmiejÄ™tność" 
                     SortExpression="employee_skill" UniqueName="employee_skill"
                     <ItemStyle HorizontalAlign="Center" Width="100px" /> 
                     <HeaderStyle HorizontalAlign="Center" /> 
                 </telerik:GridBoundColumn> 
                 <telerik:GridBoundColumn DataField="employee_wellness" DataType="System.Double" HeaderText="Samopoczucie" 
                     SortExpression="employee_wellness" UniqueName="employee_wellness"
                     <ItemStyle HorizontalAlign="Center" Width="100px" /> 
                     <HeaderStyle HorizontalAlign="Center" /> 
                 </telerik:GridBoundColumn> 
                 <telerik:GridTemplateColumn DataField="employee_productivity" DataType="System.Double" 
                     HeaderText="Produktywność" SortExpression="employee_productivity" UniqueName="employee_productivity"
                     <ItemTemplate> 
                         <telerik:RadTextBox ID="productivity" Enabled="false" runat="server" Text='<%# Eval("employee_productivity") %>' 
                             Width="50px"
                             <DisabledStyle BorderColor="Transparent" ForeColor="Black" BackColor="Transparent" /> 
                         </telerik:RadTextBox></ItemTemplate
                     <ItemStyle HorizontalAlign="Center" Width="100px" /> 
                     <HeaderStyle HorizontalAlign="Center" /> 
                 </telerik:GridTemplateColumn> 
                 <telerik:GridTemplateColumn HeaderText="Pensja" UniqueName="salary"
                     <ItemTemplate> 
                         <telerik:RadNumericTextBox ID="salary" runat="server" NumberFormat-DecimalDigits="2" 
                             NumberFormat-GroupSeparator="" NumberFormat-DecimalSeparator="," Width="75px" 
                             Type="Currency" ShowSpinButtons="true" Text='<%# Eval("employee_salary") %>'
                             <ClientEvents OnKeyPress="recalculate" OnValueChanged="recalculate" /> 
                             <IncrementSettings Step="0.05" InterceptMouseWheel="true" /> 
                         </telerik:RadNumericTextBox> 
                     </ItemTemplate> 
                     <ItemStyle HorizontalAlign="Center" Width="100px" /> 
                     <HeaderStyle HorizontalAlign="Center" /> 
                 </telerik:GridTemplateColumn> 
                 <telerik:GridTemplateColumn HeaderText="Profit" UniqueName="profit"
                     <ItemTemplate> 
                         <telerik:RadTextBox ID="profit" runat="server" Width="50px"
                         </telerik:RadTextBox></ItemTemplate
                     <ItemStyle HorizontalAlign="Center" Width="100px" /> 
                     <HeaderStyle HorizontalAlign="Center" /> 
                     <FooterTemplate> 
                         <telerik:RadTextBox ID="total" Enabled="false" runat="server" Width="50px"
                             <DisabledStyle BorderColor="Transparent" ForeColor="Black" BackColor="Transparent" /> 
                         </telerik:RadTextBox> 
                     </FooterTemplate> 
                 </telerik:GridTemplateColumn> 
             </Columns> 
         </MasterTableView> 
     </telerik:RadGrid> 

The grid is in non-edit mode. I have NumericTextBoxes in normal, default view.

I enabled sorting through few columns.

The problem is that when I enter some value in NumericTextBox and press sort, the data is sorting ok, but I losing the value inserted before sorting.

How to prevent it?

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 16 Nov 2009, 05:00 PM
Hi Grzesiek,

You cannot actually prevent this, unless you update your data source with the changed textbox value on blur or some other event. RadGrid rebinds on sorting/paging/filtering and your modified values are lost if you do not save them in your data source.

All the best,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Grzesiek
Top achievements
Rank 2
Iron
Answers by
Veli
Telerik team
Share this question
or