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

Associate Unique ID's for each 'star'

1 Answer 38 Views
Rating
This is a migrated thread and some comments may be shown as answers.
Ben Slater
Top achievements
Rank 1
Ben Slater asked on 01 Feb 2010, 05:02 AM
Is there any way to achieve this?

Example: I have a RadRating control with an ItemCount of 5, I would like to have each item within the Rating control to have its own unique identifier.

ie. 'RadRating1 1', 'RadRating1 2', 'RadRating1 3', 'RadRating1 4', 'RadRating1 5'

I started digging and would assume to achieve this functionality I would have to modify the RadRating .js? If so, how?

Thanks

Edit: Thinking about it a bit more, I'd need the classes to have it's own number. Please see the example below. I have altered the HTML render to how I would like it, primarily the A tag's class and ID.

<div class="RadRating RadRating_Test" id="ctl00_ContentPlaceHolder1_rptLatestOffers_ctl02_RadRating1" style="width: 89px; float: left; height: 22px;" RowID="2" WineID="2432" control="[object Object]">  
  <ul class="rrtItem" _events="[object Object]">  
    <li class="rrtSelected">  
      <title="1" class="1" id="1" href="#"></a> 
    </li> 
    <li class="rrtSelected">  
      <title="2" class="2" id="2" href="#"></a> 
    </li> 
    <li class="rrtSelected">  
      <title="3" class="3" id="3" href="#"></a> 
    </li> 
    <li class="rrtSelected">  
      <title="4" class="4" id="4" href="#"></a> 
    </li> 
    <li class="rrtSelected">  
      <title="5" class="5" id="5" href="#"></a> 
    </li> 
  </ul> 
</div> 

1 Answer, 1 is accepted

Sort by
0
Tsvetie
Telerik team
answered on 04 Feb 2010, 10:55 AM
Hello Ben Slater,
You can set an id and class attribute for the items of the rating control the following way:
<telerik:RadRating ID="RadRating2" runat="server" Precision="Item" ItemCount="5"
    OnClientLoad="OnClientLoad">
</telerik:RadRating>
 
<script type="text/javascript">
    function OnClientLoad(sender,args)
    {
        var aElements = sender.get_element().getElementsByTagName("A");
        for (var i = 0,length = aElements.length;i < length;i++)
        {
            var element = aElements[i];
            element.id = "element" + (i + 1);
            Sys.UI.DomElement.addCssClass(element,"class" + (i + 1));
        }
    }
</script>

Regards,
Tsvetie
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
Rating
Asked by
Ben Slater
Top achievements
Rank 1
Answers by
Tsvetie
Telerik team
Share this question
or