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

[Solved] RadGrid Selected Item Issue

3 Answers 212 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Meghna
Top achievements
Rank 1
Meghna asked on 20 May 2009, 07:33 AM
I have an requirement of selecting the first item/row of the RadGrid selected on client side. I have used following code snippet:--

var masterTable = $find("<%=RadGrid1.ClientID%>").get_masterTableView();
var dataItem
= masterTable.get_dataItems()[0];
dataItem.set_selected(true);

But somehow it is not working. Do i need to set some property of the RadGrid. I am getting the follwoing java script error:--

this._owner._owner._selection is null

Can any one help me?

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 20 May 2009, 08:51 AM
Hello Meghna,

To avoid the javascript error that you get you would have to set the AllowRowSelect property of the grid to true as shown below:
aspx:
 <telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server"
   <MasterTableView DataSourceID="SqlDataSource1">        
    <ClientSettings>  
       <Selecting AllowRowSelect="true" /> 
    </ClientSettings> 

Thanks
Princy.
0
Accepted
Pavlina
Telerik team
answered on 20 May 2009, 09:56 AM
Hello Meghna,

I was able to replicate the issue you mentioned, in order to avoid it you need to add AllowRowSelect property to true as shown bellow.
ASPX:
<ClientSettings> 
    <ClientEvents OnGridCreated="GridCreated" /> 
    <Selecting AllowRowSelect="true" /> 
</ClientSettings> 

Additionally, I am sending you a small runnable application that demonstrates the needed approach.
Give it a try and see if it works for you.

Kind regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Suneco
Top achievements
Rank 2
answered on 10 Jun 2009, 02:39 PM
Nice,

I had the same problem it works here to now. But this message is to every one, download the project and you see that there is a little javascript inside. You need to use it as well to get it working.

Thanks for posting a project Pavlina.

My regards,
Jeroen Speldekamp
Tags
Grid
Asked by
Meghna
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Pavlina
Telerik team
Suneco
Top achievements
Rank 2
Share this question
or