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

cannot get OnRowSelected to fire

4 Answers 85 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.
Steve A
Top achievements
Rank 1
Steve A asked on 14 Apr 2010, 04:00 AM
I cannot get the following code to fire clientside events, grid renders fine,pages sorts etc, any help appriciated (using latest version) :    




    <%= Html.Telerik().Grid<PersonSearchListModel>()  
        .Name("Test")  
        .Columns(columns =>  
        {  
            columns.Bound(c => c.PersonID).Width(1);  
            columns.Bound(c => c.FirstName).Width(5);  
            columns.Bound(c => c.MiddleName).Width(4);  
            columns.Bound(c => c.LastName).Width(5);  
            columns.Bound(c => c.Phone).Width("50");  
            columns.Bound(c => c.Address).Width(200);  
            columns.Bound(c => c.SSN).Width(50);  
            columns.Bound(c => c.HICN).Width(10);  
            columns.Bound(c => c.DOB).Width(20);  
            columns.Bound(c => c.EnrollmentStatus).Width(20);  
            columns.Bound(c => c.AuthorizedRep).Width(20);  
            columns.Bound(c => c.AuthorizedRepPhone).Width(20);  
 
        }).ClientEvents(events => events.OnLoad("onLoad").OnDataBinding("onDataBinding").  
            OnRowDataBound("onRowDataBound").  
            OnRowSelected("onRowSelected").  
            OnDataBound("onDataBound"))  
            .Selectable()  
 
        .BindTo((IEnumerable<PersonSearchListModel>)Model)                           
        .Pageable(ww=> ww.PageSize(25))  
        .DataKeys(keys=> keys.Add(my=>my.PersonID))      
        .Sortable()  
                       
 
    
          
        %>  
 
        <script type="text/javascript">  
            function onRowSelected(e) {  
 
                var customerID = e.row.cells[0].innerHTML;  
                alert(customerID);  
 
                // update ui text  
               // $('#customerID').text(customerID);  
 
                // rebind the related grid  
              //ordersGrid.rebind({  
              //    customerID: customerID  
              //});  
            }  
</script>  

4 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 14 Apr 2010, 08:34 AM
Hello Steve Atchue,

The grid should be made Selectable() first.

Regards,
Atanas Korchev
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.
0
Steve A
Top achievements
Rank 1
answered on 14 Apr 2010, 01:08 PM
Atanas, thanks for your response. It was "selectable"  I am not sure if you meant, the order in which
the selectable method was called ??
At any rate the following code ended up working for us.
The only thing different was the way it was rendered, would that make a difference ?



         Response.Write(Html.Hidden(
"SelectedPersonId"));    // value holder for other links in the master page.   
            Html.Telerik().Grid<PersonSearchListModel>()  
                            .Name("Telerik_SearchResults")  
                            .Columns(columns =>{  
                                        columns.Bound(c => c.PersonID).Title("ID");  
                                        columns.Bound(c => c.FirstName).Title("First");  
                                        columns.Bound(c => c.MiddleName).Title("Middle");  
                                        columns.Bound(c => c.LastName).Title("Last");  
                                        columns.Bound(c => c.Phone).Title("Phone");  
                                        columns.Bound(c => c.Address).Title("Address");  
                                        columns.Bound(c => c.SSN);  
                                        columns.Bound(c => c.HICN);  
                                        columns.Bound(c => c.DOB).Title("Date of Birth").Format("{0:MM/dd/yyyy}");  
                                        columns.Bound(c => c.EnrollmentStatus);  
                                        columns.Bound(c => c.AuthorizedRep);  
                                        columns.Bound(c => c.AuthorizedRepPhone);  
                                     }).ClientEvents(events => events  
                                                                .OnLoad("Telerik_SearchResults_Load")  
                                                                .OnRowSelected("Telerik_SearchResults_RowSelected")  
                            )  
                            .Selectable()  
                            .BindTo(Model.SearchResults)  
                            .Pageable(settings => settings.PageSize(Model.ResultsPerPage))  
                            .DataKeys(keys => keys.Add(my => my.PersonID))  
                            .Sortable(settings => settings.Enabled(true).SortMode(GridSortMode.SingleColumn)).Render()  
                            
0
Steve A
Top achievements
Rank 1
answered on 15 Apr 2010, 12:47 PM
Atanas,

It appears that it was the placement of the ScriptRegistrar. We ended up adding something like this at the end of the masterpage.

Html.Telerik().ScriptRegistrar().jQuery(

false).DefaultGroup(group => group.Add("telerik.common.min.js").Add("telerik.grid.min.js"))

 

0
Jack Ma
Top achievements
Rank 1
answered on 20 Apr 2010, 02:31 AM
Hi Steve,
     I tried with your commented change in the scripteregister, but still not help, i have same clientevent not invoked problem.

Jack
Tags
Grid
Asked by
Steve A
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Steve A
Top achievements
Rank 1
Jack Ma
Top achievements
Rank 1
Share this question
or