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

Sort Expression and Image on GridCalculatedColumn

1 Answer 132 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Farhan
Top achievements
Rank 1
Farhan asked on 17 Jan 2012, 10:21 PM
Hi,
   I have been trying to get this resolved. I have a grid with a GridCalculatedColumn, this column combines two Data fields and shows them together. I want to specify the Grid Sort Expression for this column in the grid so when the grid initially comes up its sorted by this column and the little sorting image in the column header is placed there to show the user the default column thats sorted. What should I put in the GridSortExpression's FieldName?  I can not seem to get this, It seems with a grid bound column the image appears since its a single datafield but how can I do the same thing with a grid calculated column *Updated* I actually have noticed the same issue with GridTemplateColumns as well, please let me know, thanks in advance!!

<SortExpressions>
       <telerik:GridSortExpression FieldName="OriginCity" />
 </SortExpressions>
  
  
 <telerik:GridCalculatedColumn UniqueName="Origin" HeaderText="Origin" AutoPostBackOnFilter="true"     
       SortExpression="{0} , {1}"
       DataFields="OriginCity, OriginState" Expression='{0} + " " + {1}'>
         <HeaderStyle HorizontalAlign="Left" VerticalAlign="Bottom" />
         <ItemStyle HorizontalAlign="Left" />
</telerik:GridCalculatedColumn>

1 Answer, 1 is accepted

Sort by
0
Farhan
Top achievements
Rank 1
answered on 18 Jan 2012, 07:45 PM

I figured it out, I was trying to do something in the Item_Created Event in the grid, and looked at the

RadGrid1.MasterTableView.SortExpressions[0].FieldName when sorting for another column and it came out to be "OriginResult" It added "Result" to the uniquename for the column I guess for the GridCalculatedColumn. I set this as the Grid Sort Expression and it worked and now its displaying the sort arrow on the column. Hope this helps someone else too :)

Tags
Grid
Asked by
Farhan
Top achievements
Rank 1
Answers by
Farhan
Top achievements
Rank 1
Share this question
or