
Per Holmqvist
Top achievements
Rank 2
Per Holmqvist
asked on 16 Feb 2009, 11:59 PM
I have a problem
I'm running a GridViewlookUpColumn with ID and name.
The lookup displays the name so it's working fine.
BUT, if i click the header it sorts by the ID and not by the name.
How to set that??
I'm running a GridViewlookUpColumn with ID and name.
The lookup displays the name so it's working fine.
BUT, if i click the header it sorts by the ID and not by the name.
How to set that??
9 Answers, 1 is accepted
0
Hello Per Holmqvist,
I suggest that you change your column to contain the ID data and the ID is set as ValueMember for the GridViewLookUpColumn. Hence, RadGridView stores the id as cell value and sorts using this value. You should change the ValueMember to be the Name.
I hope this helps. Do not hesitate to write back if you need further assistance.
Greetings,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I suggest that you change your column to contain the ID data and the ID is set as ValueMember for the GridViewLookUpColumn. Hence, RadGridView stores the id as cell value and sorts using this value. You should change the ValueMember to be the Name.
I hope this helps. Do not hesitate to write back if you need further assistance.
Greetings,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

Per Holmqvist
Top achievements
Rank 2
answered on 17 Feb 2009, 11:10 AM
Thanks for your reply, but when I changed like your example no prodyctname was shown in the column.
My tables are like this
The lookup table called Products have
productid and name
The Gridtable have a column named ProductID
In the Grid i want to display the productname and when click on the sorting column it should be sorted as the productnames and not the productIDs.
My Code for the Grid
GridViewLookUpColumn1.DataSource = Me.ProductsBindingSource | |
GridViewLookUpColumn1.DataType = GetType(Integer) | |
GridViewLookUpColumn1.DisplayMember = "Name" | |
GridViewLookUpColumn1.FieldAlias = "Product" | |
GridViewLookUpColumn1.FieldName = "ProductID" | |
GridViewLookUpColumn1.HeaderText = "Product" | |
GridViewLookUpColumn1.IsPinned = True | |
GridViewLookUpColumn1.MinWidth = 100 | |
GridViewLookUpColumn1.SortOrder = Telerik.WinControls.UI.RadSortOrder.Ascending | |
GridViewLookUpColumn1.UniqueName = "Product" | |
GridViewLookUpColumn1.ValueMember = "ProductId" | |
GridViewLookUpColumn1.Width = 100 |
Any more suggestions?
0
Hello Per Holmqvist,
The DisplayMember property can be used only for visualizing the data, you can't sort using the value of this property.
You should store the Name value in the cell if you want to sort by this field. So, I suggest that you change the DataType to String and the ValueMember to Name. Here is a sample:
If this doesn't solve your issue, please send me the source code of your application. This will help me find the best possible solution.
I am looking forward to your reply.
Sincerely yours,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
The DisplayMember property can be used only for visualizing the data, you can't sort using the value of this property.
You should store the Name value in the cell if you want to sort by this field. So, I suggest that you change the DataType to String and the ValueMember to Name. Here is a sample:
GridViewLookUpColumn1.DataSource = Me.ProductsBindingSource |
GridViewLookUpColumn1.DataType = GetType(String) |
GridViewLookUpColumn1.DisplayMember = "Name" |
GridViewLookUpColumn1.FieldAlias = "Product" |
GridViewLookUpColumn1.FieldName = "ProductID" |
GridViewLookUpColumn1.HeaderText = "Product" |
GridViewLookUpColumn1.IsPinned = True |
GridViewLookUpColumn1.MinWidth = 100 |
GridViewLookUpColumn1.SortOrder = Telerik.WinControls.UI.RadSortOrder.Ascending |
GridViewLookUpColumn1.UniqueName = "Product" |
GridViewLookUpColumn1.ValueMember = "Name" |
GridViewLookUpColumn1.Width = 100 |
If this doesn't solve your issue, please send me the source code of your application. This will help me find the best possible solution.
I am looking forward to your reply.
Sincerely yours,
Jack
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

Per Holmqvist
Top achievements
Rank 2
answered on 17 Feb 2009, 01:05 PM
Hi Jack.
Thanks for very prompt responds ;)
Unfortunately it didn't solve the case.
I opened up a supportticket (191648 ) and attached my code so you can se why i don't get it working.
Best regards Pelle
Thanks for very prompt responds ;)
Unfortunately it didn't solve the case.
I opened up a supportticket (191648 ) and attached my code so you can se why i don't get it working.
Best regards Pelle
0
Hi Per Holmqvist,
Please find the answer to your question in the support ticket.
All the best,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Please find the answer to your question in the support ticket.
All the best,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

Per Holmqvist
Top achievements
Rank 2
answered on 18 Feb 2009, 01:24 PM
Unfortunately it is not possible to sort the columns in a relationdatabase where you relate on the IDs (Common behavior)
I hope this is a feature you will add in the future cause it is almost the same oproblem when exporting to Excel, you dont get the visual value, but the valuemember.
Perhaps have an hidden column in the grid that have the sortvalues?
I hope this is a feature you will add in the future cause it is almost the same oproblem when exporting to Excel, you dont get the visual value, but the valuemember.
Perhaps have an hidden column in the grid that have the sortvalues?
0
Hello Per Holmqvist,
Indeed, there is an approach using a hidden column in RadGridView. For additional information, please refer to your support ticket.
Greetings,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Indeed, there is an approach using a hidden column in RadGridView. For additional information, please refer to your support ticket.
Greetings,
Nikolay
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

Kevin Meyer
Top achievements
Rank 1
answered on 23 Sep 2009, 08:09 PM
We're still having this same problem. Has it been resolved in recent build? I'm going to try setting the ValueMember to Name to see if that works. Thanks.
0
Hi Kevin Meyer,
RadGridView does its default sorting operation according to its cells' values only and this is valid for all the data columns. For more custom scenarios such as sorting by DisplayMember, you can either use Custom Sorting or you can sort by a hidden column containing the display member values.
Best wishes,
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.