I am using telerik grid internal sorting functionality.
I have set following properties -
AllowNaturalSort="false"
radGrid.MasterTableView.AllowSorting = true;
Issue -
If I click on header text of column, data get sorted but if I try to click on image for sorting, sorting is not working only page get postbacks.
13 Answers, 1 is accepted
I am afraid we are not able to reproduce this issue locally. Can you please try reproducing the same problem in this online example.
Greetings,
Pavlina
the Telerik team

Hi,
Can you provides us demo application for RadGrid with sorting?
We need to set following properties –
AllowNaturalSort ="false"
radGrid.MasterTableView.AllowSorting = true;
radGrid.datasource at runtime.
radGrid.Columns[index].SortAscImageUrl at runtime.
radGrid.Columns[index].SortDescImageUrl at runtime.
Also we have following queries -
Can we need to set DataSource & DataBind again after sort click on any column?
Same code works when we set datasource at desing time.
Please support us on this issue.
Regards,
Ganesh
Attached to this message is a simple working project which handles the desired functionality. Give it a try and let me know if it helps.
Greetings,
Pavlina
the Telerik team

Thanks for your reply
As per your sample application we have attached “Office2007” Skin to radGrid.
We have following observations
1)We are got following rendered HTML for Office2007 skin.
<input type="button" class="rgSortAsc" title="Sorted asc" onclick="javascript:__doPostBack('accountUserDetails$GrdGroup$ctl00$ctl02$ctl00$ctl01','')" value=" " name="accountUserDetails$GrdGroup$ctl00$ctl02$ctl00$ctl01"/>
In above case sorting working fine on icon as well as header text
2) We are got following rendered HTML when we attached our custom skin.
<input type="image" alt="Sorted asc" src="/sorteduparrow.gif" title="Sorted asc" name="accountUserDetails$grdAccount$ctl00$ctl02$ctl00$ctl02"/>
In above case onclick is not rendered which was rendered in previous case as shown in red.
Also note that input type attribute also rendered not similler.
Most probably there is something wrong with the custom skin. Please send it (including the CSS file and images) if you need further assistance.
Best wishes,
Pavlina
the Telerik team

Hello
Another observations regarding this issue are:
1) If I custom sort using OnSortCommand of telerik sorting on header image works fine.
2) But if I sort telerik inbuilt sorting without using OnSortCommand sorting not working on header image.
3) In both above cases sorting image rendered as input type=”image” only.
But its works only in 1st case.
Regards,
Ganesh Gaikwad
Based on the provided information I am not sure what could have gone wrong in your case. Therefore I suggest that you open a formal support ticket and either send us a runnable project or at least the problematic pages, and code files for further research.
All the best,
Pavlina
the Telerik team

If I assign an Image for the header, sorting is broken. Ajax Requests are not fired when the image is clicked, just a post back with no sorting.
If the column has a sort indicator, and one clicks the sort indicator instead of the header image, it works properly.
As I said in the previous post, it is hard to determine what is causing this problem. In any case, to properly address the issue, it will be best if you open a formal support ticket, and send us a small working project, demonstrating your setup, and showing the unwanted behavior. We will debug it locally, and get back to you with more information on the matter.
All the best,
Pavlina
the Telerik team

We are facing same issue but want to highlight that we have disabled ViewState of Rad Grid and are using NeedDatasource event. It we are enabling ViewState of RadGrid it is working fine. Is there something that Headertext viewstate is maintained and not for the sort icon.
Thanks,
Chanda.
For more information about grid ViewState you can check the help article below:
http://www.telerik.com/help/aspnet-ajax/grid-viewstate-optimization.html
Kind regards,
Pavlina
the Telerik team

how can i change the corresponding column header in the grid to show the SortIcon
i have already tried
radgrid.Columns[3].SortAscImageUrl="image url";
radgrid.Columns[3].ShowSortIcon=true;
but this is only applying when the normal grid header sort event fires
not from outside of the grid (from dropdown)
please provide a solution for this ASAP
To achieve your goal you can handle ItemCreated server side event and set sort icon for the corresponding sort order as shown below:
protected
void
grid_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridHeaderItem)
{
GridHeaderItem header = (GridHeaderItem)e.Item;
Image img =
new
Image();
img.ID =
"Image1"
;
img.ImageUrl =
"~/Images/SortAsc.gif"
;
header[
"CustomerID"
].Controls.AddAt(1, img);
if
(grid.MasterTableView.SortExpressions.Count > 0 && grid.MasterTableView.SortExpressions[0].FieldName ==
"CustomerID"
)
{
if
(grid.MasterTableView.SortExpressions[0].SortOrder != GridSortOrder.Ascending)
{
header[
"CustomerID"
].Controls.Remove(img);
}
}
}
}
I hope this works for you.
Regards,
Pavlina
the Telerik team