Hi All,
Is there a way to tell RadFilterNumericFieldEditor not to use thousands separator in its numeric editor? For example, I have columns that display Year or IDs. In the filter editor I want to see ‘2012’ and not ‘2,012’. For the column filters I did it with setting NumberFormat.GroupSeparator = "" on filteringItem, but cannot find a way to do it for RadFilter.
Thanks.
Elena.
3 Answers, 1 is accepted
0
Hi Elena,
You could achieve your scenario by overriding the Page PreRenderComplete method find all RadNumericTextBox controls and set their custom number format as shown below.
All the best,
Antonio Stoilkov
the Telerik team
You could achieve your scenario by overriding the Page PreRenderComplete method find all RadNumericTextBox controls and set their custom number format as shown below.
protected override void OnPreRenderComplete(EventArgs e){ base.OnPreRenderComplete(e); IEnumerable<RadNumericTextBox> controls = FindControlsOfType<RadNumericTextBox>(RadFilter1); foreach (RadNumericTextBox textBox in controls) { textBox.NumberFormat.GroupSeparator = string.Empty; }}public static IEnumerable<T> FindControlsOfType<T>(Control parent) where T : Control{ foreach (Control child in parent.Controls) { if (child is T) { yield return (T)child; } else if (child.Controls.Count > 0) { foreach (T grandChild in FindControlsOfType<T>(child)) { yield return grandChild; } } }}All the best,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Elena
Top achievements
Rank 1
answered on 01 Feb 2013, 09:37 PM
Antonio,
Thank you for the code. It was tricky to convert to VB so I used List instead as follows:
It seems to work, I just want to make sure that I did not miss anything.
I want to apply the rule for a subset of Numeric TextBoxes based on the original column's DataType. Please let me know if there is an easier way to find the DataType of the original column.
Thanks,
Elena.
Thank you for the code. It was tricky to convert to VB so I used List instead as follows:
Public Sub OnPreRenderComplete(ByVal e As EventArgs) Dim controls As New List(Of RadNumericTextBox) FindControlsOfType(Of RadNumericTextBox)(myRadFilter, controls) For Each textBox As RadNumericTextBox In controls For Each col In myRadGrid.MasterTableView.RenderColumns() If col.HeaderText = DirectCast(textBox.Parent.Controls(0), System.Web.UI.WebControls.HyperLink).Text Then If (col.DataType.Name = "Int32" Or col.DataType.Name = "Int16") Then textBox.NumberFormat.GroupSeparator = String.Empty End If End If Next NextEnd SubPublic Shared Sub FindControlsOfType(Of T As Control)(parent As Control, ByRef myList As List(Of T)) For Each child As Control In parent.Controls If TypeOf child Is T Then myList.Add(DirectCast(child, T)) ElseIf child.Controls.Count > 0 Then FindControlsOfType(Of T)(child, myList) End If NextEnd SubIt seems to work, I just want to make sure that I did not miss anything.
I want to apply the rule for a subset of Numeric TextBoxes based on the original column's DataType. Please let me know if there is an easier way to find the DataType of the original column.
Thanks,
Elena.
0
Hi Elena,
You could modify your code by checking the RadNumericTextBox NamingContainer which is RadFilterSingleExpressionItem and access its Expression.FieldName value and compare it to the column DataField.
Greetings,
Antonio Stoilkov
the Telerik team
You could modify your code by checking the RadNumericTextBox NamingContainer which is RadFilterSingleExpressionItem and access its Expression.FieldName value and compare it to the column DataField.
Dim fieldName As String = DirectCast(textBox.NamingContainer, Telerik.Web.UI.RadFilterSingleExpressionItem).Expression.FieldNameIf col.DataField = fieldName Then 'your code logicEnd IfGreetings,
Antonio Stoilkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.