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

[Solved] OnRowSelected when the page loads.

1 Answer 119 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kira
Top achievements
Rank 1
Kira asked on 07 Apr 2010, 01:14 PM
I use Grid with Client Selection (ASP.NET MVC) and in my application, one of the lines is checked automatically once the page is loaded, based on an ID received through the Model. But I could not find a way to run the event "OnRowSelected" to this line, when the page finishes loading. I tried "onload", "OnRowDatabound", "OnInit" and had no success. I just need to know how to run an event for a row when the page finishes loading. I very much appreciate any help! Below is one of my attempts: 

(The jQueryFunction is the same function)

<%= Html.Telerik().Grid(Model) 
    .Name("Name") 
    .Columns(columns => 
    { 
        columns.Bound(c => c.MyId).Title("ID").Width(130); 
    }) 
    .DataBinding(dataBinding => dataBinding.Ajax().Select("Action", "Controller")) 
    .Pageable() 
    .Selectable() 
    .RowAction(row => row.Selected = row.DataItem.MyId.Equals(Model.MyId)) 
    .ClientEvents(events => events.OnRowSelected("jQueryFunction").OnLoad("jQueryFunction")) 
%> 

1 Answer, 1 is accepted

Sort by
0
Accepted
Alex Gyoshev
Telerik team
answered on 07 Apr 2010, 01:44 PM
Hello Kira,

In the OnLoad client-side event, find the selected row and fire the jQueryFunction handler on it, like this:

function onLoad() {
    var pseudoEvent = { row: $('tr.t-state-selected', this.element) };
   jQueryFunction.call(this, pseudoEvent);
}


Regards,
Alex Gyoshev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Kira
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Share this question
or