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

Decimal Sorting With GridViewDatacolumn

10 Answers 118 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Siddhart
Top achievements
Rank 1
Siddhart asked on 25 Apr 2013, 02:09 PM

I am Using telerik radcontrols with silverlight4.0. Here I am having currency column in my radgridview, but the problem happening it is not getting sorted in ascending and descending way, For example:

 1500.44 , 12229.21 , 1021.30 230.15 , 1400.36

The order should be

230.15,1021.30,1400.36,1500.44,12229.21

Could anyone please throw a light how we can acquire the sorting these values?

10 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 25 Apr 2013, 03:45 PM
Hello,

Have you bound the column to values of type decimal? If so then they should be sorted fine.
 

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Siddhart
Top achievements
Rank 1
answered on 25 Apr 2013, 03:46 PM
Hello Dildie,

I am bit Unaware of Bounding the Column, Could you please the Step Process for it??

Thanks
Siddharth
0
Dimitrina
Telerik team
answered on 25 Apr 2013, 03:51 PM
Hello,

What I meant is to check if the source property shown in the currency column is of type Decimal. You can also check whether the DataType for the currency column is Decimal.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Siddhart
Top achievements
Rank 1
answered on 25 Apr 2013, 03:54 PM
Ohh Yes, I bound the GridViewDataColumn to Decimal Datatype, Still it doesnt sorting out.

Thanks
Siddharth
0
Dimitrina
Telerik team
answered on 25 Apr 2013, 04:03 PM
Hello,

I am afraid that I am not able to observe such a behavior. 

Would it be possible for you to prepare a simple project demonstrating your implementation. That way I can debug it locally to check what the problem would be. 

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Siddhart
Top achievements
Rank 1
answered on 25 Apr 2013, 04:08 PM
Hi,

Well I made a Converter for parsing string values to Decimal and i bound in this way ,

 

 

 

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

 

{

 

 

string strVal = value.ToString();

 

 

 

if (string.IsNullOrEmpty(strVal))

 

 

 

return 0;

 

 

 

else

 

 

 

 

 

 

 

return double.Parse(strVal);

 

}

 

 

 

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

 

{

 

 

return "";

 

}


XAML is

 

 

 

 

<telerik:GridViewDataColumn IsSortable="True" Header="AMOUNT PAID(USD)" DataFormatString="{}{0:C2}" DataMemberBinding="{Binding AMOUNT_PAID,Converter={StaticResource GridColumnAmountPaidStringConverter}}" >

 

 

 

 


To call converter i put it in usercontrol resource,

 

 

 

 

<conv:GridColumnAmountPaidStringConverter x:Key="GridColumnAmountPaidStringConverter"/>

 

 

 

 

 

 

 

I am getting data for this column through View Model using ObservableCollection.
Thanks
Siddharth 

0
Dimitrina
Telerik team
answered on 25 Apr 2013, 04:34 PM
Hi,

Actually this behavior is then expected and by design. All data shaping operations, i.e. filtering, sorting and grouping are done over the actual raw data and not according to its visual representation on the screen.

You will need to expose a new property of type Decimal and use it instead. 
 

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Siddhart
Top achievements
Rank 1
answered on 25 Apr 2013, 04:37 PM
Hey,

Thanks For the Reply, If you dont mind Could you please brieft me how to describe the property of decimal?? Also share how we can apply Visual Representation on the screen.

Thanks for the Help.

Thanks
Siddharth
0
Dimitrina
Telerik team
answered on 25 Apr 2013, 04:43 PM
Hello,

"Visual Representation" is achieved through using Converter (as in your case). You will have to define a new Decimal Property (similar to AMOUNT_PAID, but of type Decimal, not of type string) for your business object.
 

Greetings,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Siddhart
Top achievements
Rank 1
answered on 25 Apr 2013, 05:03 PM
Hey Dildie,

Do you have any example how to define decimal property in business objects??


Thanks
Siddharth
Tags
GridView
Asked by
Siddhart
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Siddhart
Top achievements
Rank 1
Share this question
or