Events in Rating Control

25 Jan 20232 minutes to read

This section describes the rating events that will be triggered when appropriate actions are performed. The following events are available in the rating control.

BeforeItemRender

The rating control triggers the BeforeItemRender event before rendering each rating item. The RatingItemEventArgs passed as an event argument provides the details of the item to be rendered.

@using Syncfusion.EJ2.Inputs

@Html.EJS().Rating("rating").BeforeItemRender("BeforeItemRender").Render()

<script>

    function BeforeItemRender(args) {
        // Here, you can customize your code.
    }

</script>
public ActionResult BeforeItemRender()
{
    return View();
}

Created

The rating control triggers the Created event when the rendering of the rating control is completed.

@using Syncfusion.EJ2.Inputs

@Html.EJS().Rating("rating").Created("Created").Render()

<script>

    function Created(args) {
        // Here, you can customize your code.
    }

</script>
public ActionResult CreatedEvent()
{
    return View();
}

ValueChanged

The rating control triggers the ValueChanged event when the value of the rating is changed. The RatingChangedEventArgs passed as an event argument provides the details when value is changed.

@using Syncfusion.EJ2.Inputs

@Html.EJS().Rating("rating").ValueChanged("ValueChanged").Render()

<script>

    function ValueChanged(args) {
        // Here, you can customize your code.
    }

</script>
public ActionResult ValueChanged()
{
    return View();
}

OnItemHover

The rating control triggers the OnItemHover event when the rating item is hovered. The RatingHoverEventArgs passed as an event argument provides the details of the hovered item.

@using Syncfusion.EJ2.Inputs

@Html.EJS().Rating("rating").OnItemHover("OnItemHover").Render()

<script>

    function OnItemHover(args) {
        // Here, you can customize your code.
    }

</script>
public ActionResult ItemHover()
{
    return View();
}