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

Show hide tr .. /tr in edit template of a RAD Grid

1 Answer 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sabyasachi Dechaudhari
Top achievements
Rank 1
Sabyasachi Dechaudhari asked on 04 Mar 2010, 09:38 AM
I need to set the visibility of the tr from the grdProductGroup_ItemDataBound when the record is selected for editing.
Currently,
in my grdPG_ItemDataBound for Edit Item

if 
(((PG)item.DataItem).ProductGroupType == "mobile")   
{  
HtmlTableRow tr = (HtmlTableRow)item.FindControl("trMobile");   
tr.Style.Clear();  
tr.Style.Add(
HtmlTextWriterStyle.Display, "");   

& in my aspx page

 

<tr> 
<td align="right">  
<asp:Label ID="Label3" runat="server" CssClass="label"   
Text=" Product Type:"></asp:Label><span   
class="requiredFieldIndicator">*</span> 
</td> 
<td align="left" colspan="3">  
<telerik:RadComboBox ID="cboPG" runat="server" Skin="Vista" MarkFirstMatch="True" 
AppendDataBoundItems="true" AutoPostBack="false"   
OnClientSelectedIndexChanged = "ShowHidetrMobile" Font-Names="Verdana" 
Font-Size="8" >   
</telerik:RadComboBox>   
</td>   
</tr> 
<tr id="trMobile" style="display:none" runat="server" > 
<td align="right">  
<asp:Label ID="Label1" runat="server" CssClass="label"   
Text="Mobile Company:"></asp:Label><span   
class="requiredFieldIndicator">*</span> 
</td> 
<td align="left" colspan="3">  
<telerik:RadComboBox ID="cboMobileCompany" runat="server" Skin="Vista" MarkFirstMatch="True" 
AppendDataBoundItems="true" AutoPostBack="false"   
Font-Names="Verdana" 
Font-Size="8" >   
</telerik:RadComboBox>   
</td>   
</tr>   
 
all fine till here...
But how do I get the client Id of the TR in the javascript
Here is my Javascript .. any cleaner way to do it ?
function ShowHidetrMobile(obj,args)  
{  
if (obj._text=="Mobile")  
    $get("ctl00_ContentPlaceHolder1_grdProductGroup_ctl00_ctl05_trMobile").style.display="";  //Although i dont like this way
else      
    $get("ctl00_ContentPlaceHolder1_grdProductGroup_ctl00_ctl05_trMobile").style.display="none";  

 

all fine till here...But how do I get the client Id of the TR in the javascriptHere is my Javascript .. any cleaner way to do it ?

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 08 Mar 2010, 03:46 PM
Hello Sabyasachi,

Using document.getElementById("<%= SomeControl.ClientID %>") or $get("<%= SomeControl.ClientID %>") are the recommended ways to get client side reference to elements with runat property set to server.

Also if you want to get reference to the RadControls you could use $find("<%= SomeControl.ClientID %>"). What it does it to output the generated client-id in the final markup of your page.

I hope this helps.

All the best,
Radoslav
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
Sabyasachi Dechaudhari
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or