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

Automatic Formatting of results

1 Answer 21 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kurt Kluth
Top achievements
Rank 1
Kurt Kluth asked on 04 Dec 2013, 09:56 PM
Is it possible to format the RadGrid results a certain way automatically?  It appears that the filtering items automatically choose which items are available based on the text in the column.  ie. If it is text, it adds the option "starts with" but if it is a number than it has other options so

What I would like is if it is determined to be a # account that it will properly format the results with commas. 

I had found where if I put it in the RadGrid_ColumnCreated, that I could do it there but I would have over 200 columns to possibly check.

1 Answer, 1 is accepted

Sort by
0
Kurt Kluth
Top achievements
Rank 1
answered on 06 Dec 2013, 02:47 PM
Have found the solution to my problem. 

Protected Sub _SearchResults_ColumnCreated(sender As Object, e As Telerik.Web.UI.GridColumnCreatedEventArgs) Handles _SearchResults.ColumnCreated
        If e.Column.DataType.Name = "Decimal" Then
            CType(e.Column, Telerik.Web.UI.GridBoundColumn).DataFormatString = "{0:N2}"
            CType(e.Column, Telerik.Web.UI.GridBoundColumn).Groupable = True
 
            CType(e.Column, Telerik.Web.UI.GridBoundColumn).Aggregate = Telerik.Web.UI.GridAggregateFunction.Sum
            e.Column.ItemStyle.HorizontalAlign = HorizontalAlign.Right
        End If
 
        'Specify the location of the Images
        e.Column.FilterImageUrl = "../images/Grid/Filter.gif"
        e.Column.SortAscImageUrl = "../images/Grid/SortAsc.gif"
        e.Column.SortDescImageUrl = "../images/Grid/SortDesc.gif"
    End Sub
Tags
Grid
Asked by
Kurt Kluth
Top achievements
Rank 1
Answers by
Kurt Kluth
Top achievements
Rank 1
Share this question
or