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

Sort by Unbound Columns

6 Answers 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeremy Yoder
Top achievements
Rank 1
Jeremy Yoder asked on 08 Feb 2014, 12:03 AM

We have a datatable with multiple keys (RoomKey, BuildingKey, etc) but no matching IDs. I'll look these up and put them into unbound column on the server-side within ItemDataBound, which I believe is my only workaround. If there is a better way, please advise.

As a result, in the grid, for each ID field's GridBoundColumn, I've removed the DataField property. But then I can't sort by my ID fields. After searching your forum, I see this is expected... but we need to sort by them. What's the workaround to enable this?

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Feb 2014, 06:39 AM
Hi Jeremy Yoder,

Sorting functionality for the unbound columns in the RadGrid is not possible. As those columns do not contain data items, the sorting will not work. What you can do is to manually "sort" the values  by using the header click for the unbound columns.

Thanks,
Princy
0
Jeremy Yoder
Top achievements
Rank 1
answered on 10 Feb 2014, 05:15 PM

Thanks. How do I "manually sort the values by using the header click for the unbound columns"?
0
Princy
Top achievements
Rank 2
answered on 11 Feb 2014, 08:16 AM
Hi Jeremy Yoder,

Please try the following code snippet:

ASPX:
<ClientSettings>
   <ClientEvents OnColumnClick="OnColumnClick" />
</ClientSettings>

JS:
<script type="text/javascript">
  function OnColumnClick(sender, args) {
    var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();     
    masterTable.sort(args.get_gridColumn().get_uniqueName());    
    }
</script>

Thanks,
Princy
0
Lina
Top achievements
Rank 1
answered on 12 May 2014, 06:08 AM
i get an exception because there is a call to the method which perform the select with sortExpression="Test1 ASC", but there is no such field there.
0
Princy
Top achievements
Rank 2
answered on 13 May 2014, 06:25 AM
Hi Lina,

Its hard to identify the issue with so less information. Please provide your full code snippet to help you with your requirement.

Thanks,
Princy
0
Lina
Top achievements
Rank 1
answered on 13 May 2014, 06:48 AM
sorry, i replied in the link you posted instead of my original which include code sample:
http://www.telerik.com/forums/how-to-add-column-which-is-updated-using-code-and-can-be-sortable#bhpSpWD1Z0igzkvD6PNB_Q
Tags
Grid
Asked by
Jeremy Yoder
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jeremy Yoder
Top achievements
Rank 1
Lina
Top achievements
Rank 1
Share this question
or