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

custom sort on page load radgrid

7 Answers 353 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Reshma
Top achievements
Rank 1
Reshma asked on 17 Dec 2013, 10:16 AM
Hi ,

i have a radgrid in wchich there are 6 columns. I am bringing data from procedure which is sorted by say 'record_sort' but on page load i want to show it as if its sorted by record and title both.
how can i do that?

7 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Dec 2013, 11:41 AM
Hi Reshma,

You can set AllowMultiColumnSorting property to True, more than one column sort expression can be added to the table view.

ASPX:
<MasterTableView AllowMultiColumnSorting="true">
   <SortExpressions>
      <telerik:GridSortExpression FieldName="record" SortOrder="Descending" />
      <telerik:GridSortExpression FieldName="title" SortOrder="Descending" />
  </SortExpressions>

Thanks,
Princy
0
Reshma
Top achievements
Rank 1
answered on 17 Dec 2013, 11:51 AM
hi ,
adding <telerik:GridSortExpression FieldName="record" SortOrder="Descending" />
      <telerik:GridSortExpression FieldName="title" SortOrder="Descending" /

will sort my data with record and title which i dont want.i want it to get sorted by record_sort but on screen it should displa as it is sorted on record and title ascending.

is there any property which will show column header as sorted ..?
they just should LOOK as sorted but actually grid is sorted with some different column.
0
Princy
Top achievements
Rank 2
answered on 18 Dec 2013, 04:14 AM
Hi Reshma,

When you set the sort for record column as ascending all the remaining columns will be arranged according to that sorted column. You can use sort on record and the title will be displayed according to the sorted order of records.

ASPX:
<SortExpressions>
   <telerik:GridSortExpression FieldName="record" SortOrder="Ascending" />
</SortExpressions>

Thanks,
Princy
0
Reshma
Top achievements
Rank 1
answered on 18 Dec 2013, 07:32 AM
hi,
you are not getting my problem.

I am saying i have grid sorted with column RECORD_SORT which is invisible but to user on screen i want to show as grid is sorted by column Record and Title.

Can I do that???
0
Viktor Tachev
Telerik team
answered on 20 Dec 2013, 10:36 AM
Hi Reshma,

If I understand correctly you would like the grid to have no sorting, however the styles for some columns to be like they are sorted.

In order to achieve this you could use the default styles of the grid or define a custom style.

If you would like to use the default styles for RadGrid you need to set the HeaderStyle-CssClass and ItemStyle-CssClass properties to 'rgSorted'. This could be done in the markup or in the code-behind.

Markup:

<telerik:GridBoundColumn DataField="Record" HeaderText="Record" UniqueName="Record" HeaderStyle-CssClass="rgSorted" ItemStyle-CssClass="rgSorted">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Title" HeaderText="Title" UniqueName="Title" HeaderStyle-CssClass="rgSorted" ItemStyle-CssClass="rgSorted">
</telerik:GridBoundColumn>

Code-behind:

(RadGrid1.MasterTableView.GetColumnSafe("Record") as GridBoundColumn).HeaderStyle.CssClass = "rgSorted";
(RadGrid1.MasterTableView.GetColumnSafe("Record") as GridBoundColumn).ItemStyle.CssClass = "rgSorted";

If you would like to have custom styles you could set the CssClass for the columns like above to a CSS class that you have defined on the page.

Hope this helps. If you have different requirements or further instructions, please elaborate on your specific scenario and send us sample screenshots or video demonstrating the desired behavior.

Regards,
Viktor Tachev
Telerik
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 the blog feed now.
0
Reshma
Top achievements
Rank 1
answered on 23 Dec 2013, 07:47 AM
Hi,
thanks for your reply.
You have got my problem correctly.
I applied your suggestions .now my two column are looking sorted (light yello background_ however arrow image is not there.
How can i get descending arrow image.

attached scrrenshot.
0
Eyup
Telerik team
answered on 25 Dec 2013, 12:25 PM
Hi Reshma,

I have created a sample RadGrid web site to demonstrate how you can achieve the requested functionality. You will notices that upon sorting the ShipName column, it is actually getting sorted by ShipCountry. Please run the attached application and let me know if it helps you.

Regards,
Eyup
Telerik
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 the blog feed now.
Tags
Grid
Asked by
Reshma
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Reshma
Top achievements
Rank 1
Viktor Tachev
Telerik team
Eyup
Telerik team
Share this question
or