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.
Unfortunately, activation email could not send to your email. Please try again.

Rating Control In The Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

125131 Jul 23,2016 03:24 PM Jul 26,2016 05:29 AM ASP.NET MVC 1
loading
Tags: Grid
Jeffrey Stone
Asked On July 23, 2016 03:24 PM

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

Regards, Jeff

Karthick Kuppusamy [Syncfusion]
Replied On July 26, 2016 05:29 AM

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("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(175).Format("{0:C}").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   
    }    
    </script>   
  
   
   
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.   
Regards,   
K. Karthick  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;