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

Grid Sorting Focus Issue

6 Answers 69 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Swamy
Top achievements
Rank 1
Swamy asked on 12 Oct 2012, 11:36 PM
Hello,

I have a rad grid with property AllowSorting="true". I did set my sort expressions for all my columns. When i sort the columns it is working fine. Now i want to place the focus on the column link which is sorted now or on the asc/desc image button. Please advice me on this.

Thanks,
Syam.

6 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 17 Oct 2012, 05:09 PM
Hello Swamy,

You could try the following approach:
<ClientEvents OnCommand="gridCommand" />
<asp:HiddenField ID="HiddenField1" runat="server" Value="" />

  JavaScript:
function pageLoad() {
    var value = $get("<%=HiddenField1.ClientID%>").value;
    if (value != "") {
        $get(value).focus();
        $get("<%=HiddenField1.ClientID%>").value = "";
    }
}
function gridCommand(sender, args) {
    if (args.get_commandName() == "Sort") {
        var masterTable = sender.get_masterTableView();
        var column = masterTable.getColumnByUniqueName(args.get_commandArgument());
        var ascIcon = $telerik.findElement(column.get_element(), "SortAsc");
        var descIcon = $telerik.findElement(column.get_element(), "SortDesc");
        if (ascIcon.style.display != "none") {
            $get("<%=HiddenField1.ClientID%>").value = ascIcon.id;
        }
        else if (descIcon.style.display != "none") {
            $get("<%=HiddenField1.ClientID%>").value = descIcon.id;
        }
     }
  }

I hope this will prove helpful.

Greetings,
Eyup
the Telerik team
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 their blog feed now.
0
Swamy
Top achievements
Rank 1
answered on 25 Oct 2012, 09:35 PM
Hi Eyup,

Thanks for the suggestion. I followed your approach and got the following error.

"The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)."

Thanks,
Swamy.
0
Swamy
Top achievements
Rank 1
answered on 25 Oct 2012, 10:47 PM
Hi Eyup,

Finally i am not getting error now. But the value of ascIcon.style.display and descIcon.style.display
 is always none and so the hiddenfield value is not being set. Please advice me on this.

Thanks,
Swamy
0
Eyup
Telerik team
answered on 29 Oct 2012, 11:12 AM
Hello Swamy,

For the handled error, you will need to wrap your JavaScript code in RadCodeBlock as suggested in the following article:
http://www.telerik.com/help/aspnet-ajax/ajax-radscriptblock-radcodeblock.html

Could you please enable your script debugger ( FireBug for instance ) and verify that you are successfully accessing the icons and the hidden field?

Greetings,
Eyup
the Telerik team
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 their blog feed now.
0
Swamy
Top achievements
Rank 1
answered on 05 Nov 2012, 05:46 PM
Hi Eyup,

Thanks for the solution on handle error. I wrapped the script in RadCodeBlock and now everything is working as expected. I have changed my approach on this for time being but I will check it this resolves my sorting focus issue and update you at a later point of time. Also will this work with paging as well?

Thanks,
Swamy.
0
Eyup
Telerik team
answered on 06 Nov 2012, 06:20 AM
Hi Swamy,

It should work as expected. Of course, you will need to implement it according to your specific scenario.

All the best,
Eyup
the Telerik team
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 their blog feed now.
Tags
Grid
Asked by
Swamy
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Swamy
Top achievements
Rank 1
Share this question
or