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

checkbox template EJ2 Grid

Hi. I can't get the column template to work with the checkbox in the EJS grid:

            <script type="text/x-jsrender" id="isInRoleTemplate">
                <input id="isInRoleCheckbox" type="checkbox" {{if UserIsInRole}} checked {{/if}} onclick="isInRoleCheckbox_click(this)" />
            </script>

            @{
                List<object> commands = new List<object>();
                commands.Add(new { type = "Edit", buttonOption = new { iconCss = "e-icons e-edit", cssClass = "e-flat" } });
                commands.Add(new { type = "Delete", buttonOption = new { iconCss = "e-icons e-delete", cssClass = "e-flat" } });
                commands.Add(new { type = "Save", buttonOption = new { iconCss = "e-icons e-update", cssClass = "e-flat" } });
                commands.Add(new { type = "Cancel", buttonOption = new { iconCss = "e-icons e-cancel-icon", cssClass = "e-flat" } });
            }


            <ejs-grid id="gridRoles" width="600" height="500" allowPaging="true" allowResizing="true" allowSorting="true"
                      allowFiltering="true"
                      toolbar="@(new List<string>() {"Search", "Add"})"
                      load="onGridRolesLoad" actionComplete="roleActionComplete" actionFailure="roleActionFailure">
                <e-data-manager adaptor="UrlAdaptor" url="Admin/Roles_Read" insertUrl="Admin/Role_Add" updateUrl="Admin/Role_Update"
                                removeUrl="Admin/Role_Delete"></e-data-manager>
                <e-grid-editsettings allowEditing="true" mode="Dialog" template="#RoleDialogTemplate" allowAdding="true" allowDeleting="true"></e-grid-editsettings>
                <e-grid-filterSettings type="Excel"></e-grid-filterSettings>
                <e-grid-pagesettings pageSize="10"></e-grid-pagesettings>
                <e-grid-columns>
                    <e-grid-column field="UserIsInRole" allowEditing="false" template="#isInRoleTemplate" width="90" headerText="isInRole"></e-grid-column>
                    <e-grid-column field="Name" headerText="Role" textAlign="Left" width="120"></e-grid-column>
                    <e-grid-column field="Id" width="150" isPrimaryKey="true" headerText="Id" allowEditing="false"></e-grid-column>
                    <e-grid-column width="100" commands="commands"></e-grid-column>
                </e-grid-columns>
            </ejs-grid>

Everything works as expected, except for the column with the template (UserIsInRole).
What am I doing wrong? If you can-an example.
Thanks.


3 Replies

MS Madhu Sudhanan P Syncfusion Team November 29, 2018 12:23 PM UTC

Hi Costa, 

Thanks for contacting Syncfusion support. 

The template placeholder is used incorrectly in the code which is the cause of the issue. Please modify your template as follows. 


  <script type="text/x-jsrender" id="isInRoleTemplate"> 
   <input id="isInRoleCheckbox" type="checkbox"  ${if (UserIsInRole)} checked ${/if} /> 
 </script> 


For more information on using template engine and its syntax please refer the below link. 


Regards, 
Madhu Sudhanan P 



CO Costa November 29, 2018 01:37 PM UTC

Thanks!


MS Madhu Sudhanan P Syncfusion Team November 30, 2018 04:29 AM UTC

Hi Costa,  

Thanks for the update. Please get back to us if you require further assistance.  

Regards,  
Madhu Sudhanan P 


Loader.
Live Chat Icon For mobile
Up arrow icon