Hello
In my ultrawingrid, for one of the column I need to show currency symbol (like $20,000), so for this the datatype for the column is given as String, so since it is a string datatype it is sorting alphabatically, but I need to sort this according to the amount value given on header click action.
If you want to show a currency symbol in a column, you don't need to store the data as a string. Storing numeric values as strings will cause problems with sorting, filtering, and other areas.
What you should do is store the data as Currency or Decimal and then use the Format property of the grid column to format the display as currency.
I had given the format as e.Layout.Bands(0).Columns("Loan Amount").Format = "$#,##0.00"
but the problem here is if the value is negative it is showing like -$20,000 but it supposed to show like ($20,000)
Then you need to account for that in your Format. The Format property just calls ToString on the Value of the cell and passes in the format you specified. So check out the Microsoft documentation on the formats available for the data type of your column. I'm pretty sure that most numeric types allow you to specify different formats for positive, zero, and negative numbers separated by a semi-colon.
Thanks
"$#,##0.00;($#,##0.00)" this worked good.
But also some of the values of the column should contain NA.
In my application loan amount field is optional, user may enter the value or leave it blank.
If user does not enter value it need to show the value as NA in the grid.
The possible values are $20,200 or ($20,00) or $0.00 or NA
Then your format needs to specify a different format for the 0 value.
In my grid the values 0 and NA are different.
One of the records can have NA value which is supposed to be string, so how can I sort the column numerically?
I only need is sort the column alphanumerically (numerics first, strings next).
How did you manage to show NA dfifferent from 0 ??I Just knwo format string handels 3 states i.e. +ive number negatiev number and Zero, hows Null handeled ??Say i use nullable int in Grid (int?)
I was using sortcomparer class. I had created one hidden column and applied -1 value for nulls. On header click my original column sorts according to the hidden column.
Public Class LMSSortComparer Implements IComparer Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements System.Collections.IComparer.Compare Dim xCell As UltraGridCell = DirectCast(x, UltraGridCell) Dim yCell As UltraGridCell = DirectCast(y, UltraGridCell) If xCell.Column.Key = "Current Rate" Or xCell.Column.Key = "Rate" Or xCell.Column.Key = "Percentage Rate" Then Return Decimal.Compare(DirectCast(xCell.Row.Cells("sortRate").Value, Decimal), DirectCast(yCell.Row.Cells("sortRate").Value, Decimal)) End If