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

[Solved] Select row by client side

2 Answers 152 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.
Adam
Top achievements
Rank 1
Adam asked on 10 Jan 2011, 09:38 AM
Hello,

I would like to select a row using javascript.
Could you show me the way how to do this?

I've tried to use but there was no effect:

.RowAction(row =>

{

row.Selected = row.DataItem.Id.Equals(Model.Organization.Id);

}

my grid:

<%

 

= Html.Telerik().Grid<Wasko.Prezydencja.SystemAkredytacji.Model.Organization>()

 

.Name(

 

"OrganizationChoiseGrid")

 

.DataKeys(keys => { keys.Add(o => o.Id); })

.Columns(columns =>

{

columns.Bound(o => o.Id).Hidden(

 

true);

 

columns.Bound(o => o.Name);

columns.Bound(o => o.City.DictionaryValue.Value);

columns.Bound(o => o.Street);

columns.Bound(o => o.Number);

 

})

.DataBinding(dataBinding => dataBinding.Ajax()

.Select(

 

"AjaxSelect_OrganizationChoiseGrid", "Accreditations"))

 

.EnableCustomBinding(

 

true)

 

.Pageable(p => p.Enabled(

 

false))

 

.Sortable(s => s.Enabled(

 

false))

 

.Filterable(f => f.Enabled(

 

false))

 

.Selectable(e=>e.Enabled(

 

true))

 

 

 

.ClientEvents(events => events.OnRowDataBound("onRowDataBound"))

 

)

%>

 

 

 

<script type="text/javascript">

 

 

 

 

 

 

 

function onRowDataBound(e) {
?? HOW SELECT A ROW?
}

 

 

 

</script>

 

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 10 Jan 2011, 09:43 AM
Hi Adam,

 RowAction works only for server binding and thus has no effect in your ajax bound grid.

 The workaround is simple:

function onRowDataBound(e) {
     $(e.row).addClass('t-state-selected');
}

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
Mauro
Top achievements
Rank 1
answered on 22 May 2013, 04:26 PM
But if it isn't in the first page? Because in OnRowDataBound are available the first items, but all other items (page 2, page 3, page 4..page N) aren't available
Tags
Grid
Asked by
Adam
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Mauro
Top achievements
Rank 1
Share this question
or