We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Rating Control In The Grid

How can I use Rating control in a ASP NET MVC Grid Column?

Regards, Jeff

1 Reply

KK Karthick Kuppusamy Syncfusion Team July 26, 2016 09:29 AM UTC

Hi Jeffrey,   
Thanks for contacting Syncfusion support.   
We can render the ejRating control through ‘Edit Template’ feature of the Grid.   
Edit Template has three functions.   
Create – It is used to create the control at the time of initializing.  
Read –  It is used to read the input value at the time of saving.  
Write – It is used to assign the value to control at the time of editing 
Please refer to the below code example for further details.   
.Columns(col =>   
            col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();   
            col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add();   
            col.Field("EmployeeID").HeaderText("Rating").EditTemplate(a => { a.Create("create").Read("read").Write("write"); }).TextAlign(TextAlign.Right).Width(175).Add();   
            col.Field("ShipCity").HeaderText("Ship City").Width(110).Add();   
  <script type="text/javascript">     
              function create() {   
                  return $("<input>"); // Create the input element   
    function write(args) {   
        var gridId = args.element.parents(".e-grid").attr("id");   
        args.element.ejRating({ value: args.rowdata !== undefined ? args.rowdata["EmployeeID"] : "", modelType: "picker" }); // Render the rating control   
        $("#" + gridId + "Color_Presets").css("display", "none");   
    function read(args) {   
        var a = $("#FlatGridEmployeeID").ejRating("instance");   
        return a.getValue(); // Read the rating value   
Please refer to the below UG Documentation and online demo link to know more about EditTemplate in Grid.   
We have created a sample which can be downloaded from the below link.   
If we have misunderstood your requirement, please share more details about your requirement.   
K. Karthick  

Live Chat Icon For mobile
Up arrow icon