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

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

How to display Syncfusion controls in grid columns?

Platform: jQuery |
Control: ejGrid

Solution:

You can display the other Syncfusion Essential JavaScript controls using template property of Grid columns.

The following code example shows how to render Syncfusion Essential JavaScript ejRating control as one of the Grid column and set the value based on the column “EmployeeID”.

We have used JSRender conditional tag “if” to set value for Rating control based on condition.

 1. Render the Grid control.

 JS

<script type="text/x-jsrender" id="columnTemplate">

     {{if EmployeeID<3}}

    <input type="text" class="rating" value="3" />

    {{else EmployeeID>2 && EmployeeID<5}}

    <input type="text" class="rating" value="3" />

    {{else EmployeeID>4}}

    <input type="text" class="rating" value="5" />

    {{/if}}
</script>

 

 

JS

 

MVC

 

 

 

 

 

 

 

 

 

ASP.NET

 

 

 

 

2. You can render the ejRating control in Grid column using the templateRefresh event. If ej controls are rendered in templateRefresh event then it will re-render automatically, when any grid action is performed.

JS

               

Note: Similarly, we can bind all other Syncfusion JavaScript controls such as ejDatePicker, ejTimePicker, ejCheckBox etc as one of the column in grid.

 

The following output is displayed as a result of the above code example.

 

Figure: Grid with template column

 

 

ADD COMMENT
You must log in to leave a comment
Comments
Malcolm van Staden
Jul 19, 2022

Hi, is there a way to do this with the split button but with the target being part of the template? When we try the following, the target element is not available when the split button is created, so no options are available.

<script type="text/x-jsrender" id="columnTemplate">
            <button class="rating" data-target-id="target{{:EmployeeID}}">Actions</button>
            <ul id="target{{:EmployeeID}}" class="dropdown-menu">                
     {{if EmployeeID<3}}

<li><a rel='nofollow' href="#">Employee less than 3</a></li>

    {{else EmployeeID>2 && EmployeeID<5}}

<li><a rel='nofollow' href="#">Employee between 2 and 5</a></li>

    {{else EmployeeID>4}}

<li><a rel='nofollow' href="#">Employee greater than 4</a></li>

    {{/if}}
</script>
           function template(args){
              $(args.cell).find(".rating").each(function (obj) {
            $(this).ejSplitButton({
                targetID: $(this).data('target-id')
            });
      }
Reply

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon 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.Close Icon

Live Chat Icon For mobile