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

Set checkbox name for selection

I want to set the name for the checkbox that's generated in the listview. I've tried several things in the following example: http://jsplayground.syncfusion.com/svqyqayt , but I can't seem to make it work.

5 Replies

NP Narayanasamy Panneer Selvam Syncfusion Team July 14, 2016 10:42 AM UTC

Hi Tom Droste,   
Thanks for Contacting Syncfusion support.     
We have analyzed your query and we can set name attribute for the checkbox which is present inside the Listview control. Please refer the code sample in the code example block and also refer the below sample link.   
Code example:   
<script type="text/javascript">   
$(function () {    
$("#defaultlistbox").ejListView({showHeader: true, enableCheckMark:true, headerTitle: "Favorite",  width:400, height: 1500});   
$(".e-lv-check, .e-checkbox, .e-input").ejCheckBox({ htmlAttributes : {name:"newName"}});   
In this sample we have set name for checkbox using class name. If it is not your requirement, please let us know the scenario of you are name attribute in checkbox. So that can we help you out better.   
Narayanasamy P.   

TD Tom Droste July 15, 2016 10:23 AM UTC

It is not exactly what I'm looking for. The scenario I want to use the listview in is to bind an item to several categories. Every category has a description and an id. I would like to set the id as checkbox name so my controller can handle it from there. The best case scenario I could declare the checkbox name in the html.

SS Selvamani Sankarappan Syncfusion Team July 18, 2016 01:01 PM UTC

Hi Tom, 
Thanks for the update, 
We cannot set the name for each checkbox rendered using enableCheckMark property in ListView. Because they are appended with ListView item and doesn’t have unique id or name. In order to achieve your requirement, we suggest you to use template support to include check box in ListView component, where you can add name attribute for individual check box and get it from controller. Since we have added checkbox using template selection works only when you click on the check box element. Please refer the following sample: 

If still you face any difficulties, kindly get back to us. We will be happy to help you. 
Selvamani S 

TD Tom Droste July 18, 2016 01:36 PM UTC

Is it with the templates still possible to have a depth in the list?

SS Selvamani Sankarappan Syncfusion Team July 19, 2016 10:47 AM UTC

Hi Tom,   
Thanks for the update.  
Currently we haven’t provided with an in built support for multiple level of ListView items in template. Using JS render template we can achieve your requirement to add the depth level for ListView items. We have prepared the sample based on your requirement. Please refer the following sample:   
In above sample, the checkbox is enabled if the list item has no child elements using template support. And also you can add name attribute for individual check box and get it from controller.   
Selvamani S   

Live Chat Icon For mobile
Up arrow icon