within a GridTemplateColumn I pouplate the text property of a literal control depending on some database driven logic.
If case x set literal.text = database column x
if case y set literal.text = database column y
Since then the GridTemplateColumn can contain data from different columns I do not declaratively set the SortExpression property of the GridTemplateColumn.
How do I (in what event?) set the SortExpression property of the GridTemplateColumn programatically to be x or y?
If case x set literal.text = database column x
if case y set literal.text = database column y
Since then the GridTemplateColumn can contain data from different columns I do not declaratively set the SortExpression property of the GridTemplateColumn.
How do I (in what event?) set the SortExpression property of the GridTemplateColumn programatically to be x or y?
6 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 16 Jan 2009, 11:46 AM
Hi Morten,
Try accessing the Grid column using the column's UniqueName property and set its SortExpression to the required field in the code behind as shown below.
Thanks
Shinu
Try accessing the Grid column using the column's UniqueName property and set its SortExpression to the required field in the code behind as shown below.
RadGrid1.MasterTableView.GetColumn("TempCol").SortExpression = "ProductName"; |
RadGrid1.MasterTableView.Rebind(); |
Thanks
Shinu
0
Shinu
Top achievements
Rank 2
answered on 16 Jan 2009, 11:46 AM
Hi Morten,
Try accessing the Grid column using the column's UniqueName property and set its SortExpression to the required field in the code behind as shown below.
Thanks
Shinu
Try accessing the Grid column using the column's UniqueName property and set its SortExpression to the required field in the code behind as shown below.
RadGrid1.MasterTableView.GetColumn("TempCol").SortExpression = "ProductName"; |
RadGrid1.MasterTableView.Rebind(); |
Thanks
Shinu
0
Ruben Acon
Top achievements
Rank 1
answered on 25 Sep 2009, 10:45 PM
Is there any way to do this on the client side? I want to change the data (data field, header text and sort expression) of a specific column of the grid but I can't find where to find the sort expression. I was able to change the data field and header text like this:
var column = tableView.getColumnByUniqueName("bcFrom");
column._element.innerText = "To Address";
column._data.DataField = "ToAddress";
But it wont let me click on the column's header to sort anymore. I also tried just changing the header text, and changing the text in the rowbound, but got the same result, it wont let me sort. Finally I tried having 2 columns and just hiding/showing them, but that makes the other columns change (in size and text alignment). Any ideas on how to do this? Thanks
Ruben
var column = tableView.getColumnByUniqueName("bcFrom");
column._element.innerText = "To Address";
column._data.DataField = "ToAddress";
But it wont let me click on the column's header to sort anymore. I also tried just changing the header text, and changing the text in the rowbound, but got the same result, it wont let me sort. Finally I tried having 2 columns and just hiding/showing them, but that makes the other columns change (in size and text alignment). Any ideas on how to do this? Thanks
Ruben
0
Hello Ruben,
Setting sort expressions or chaning the sort criterion for grid columns on the client is not supported. You should consider the server-side approach proposed by Shinu - I hope this is feasible workaround for your situation.
Kind regards,
Sebastian
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.
Setting sort expressions or chaning the sort criterion for grid columns on the client is not supported. You should consider the server-side approach proposed by Shinu - I hope this is feasible workaround for your situation.
Kind regards,
Sebastian
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.
0
Ruben Acon
Top achievements
Rank 1
answered on 28 Sep 2009, 05:08 PM
No, I can't do it on the server side. How about hiding/showing the columns without it changing the size or alignment of the other columns, is there any way to achieve this on the client side?
0
Hello Ruben,
Actually you can use the sort method from the client-side API of RadGrid to trigger sorting from the client based on the data field of a certain column. Still the operation will be processed on the server.
Additionally, you can show/hide columns without modifying the sizes of the other columns using the header context menu of the grid as presented on this example:
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/headercontextmenu/defaultcs.aspx
Best regards,
Sebastian
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.
Actually you can use the sort method from the client-side API of RadGrid to trigger sorting from the client based on the data field of a certain column. Still the operation will be processed on the server.
Additionally, you can show/hide columns without modifying the sizes of the other columns using the header context menu of the grid as presented on this example:
http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/headercontextmenu/defaultcs.aspx
Best regards,
Sebastian
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.