Kendo listView with checkbox and checkbox select all checkbox

I am new to the kendo interface and am looking for a way to create a list with a checkbox, with the very first checkbox being All Option to select all the items in the list, if one is set. I created a template that allows me to add a checkbox to the elements, but I need to add the ALL checkbox on top of all the data. this is what i have been working on so far. Below (screenshot) I would like to achieve.

Here is my template:

<script type="text/x-kendo-tmpl" id="myTemplate">
    <div class="item click" data="${ProductID}">
        <input type="checkbox" class="click" />
        <span class="checkbox">#:ProductName#</span>
    </div>
</script>

http://jsfiddle.net/Archie/w6jsZ/

LIstview with checkboxes

+2
source share
2 answers

Your code is as follows: http://jsfiddle.net/Archie/w6jsZ/

<div style="width:250px;height:350px;overflow-y:scroll;">
    <div>
        <input type="checkbox" id="checkall" class="click" />
        <span class="checkbox">All</span>
    </div>
    <div id="listView" class="k-listview" >
    </div>
</div>
<script type="text/x-kendo-tmpl" id="myTemplate">

    <div class="item click" data="${ProductID}">
        <input type="checkbox" class="click" />
        <span class="checkbox">#:ProductName#</span>
    </div>
</script>

 $(document).ready(function () {

     function checkboxEventBinding()
     {
         $('#checkall').bind('click',function(e){
             if(this.checked)
             {
                 $('.item.click input').attr('checked','checked');
             }
             else
             {
                 $('.item.click input').removeAttr('checked');
             }

         })
     }
     var dataSource = new kendo.data.DataSource({
                  transport: {
                      read: {
                         url: "http://demos.kendoui.com/service/Products",
                            dataType: "jsonp"
                      }
                 }
                });
          $("#listView").kendoListView({
                dataSource: dataSource,
                template: kendo.template($("#myTemplate").html()),
              headertemplate:"<div class='item click' id='headerTemp' data='*'>       <input type='checkbox' class='click' /><span class='checkbox'>All</span></div>",
              dataBound: function(e) {
         checkboxEventBinding();
     }
            });


        });
  • Check the box (to check all) in front of the kendo list template
  • Check-all, .
  • .

//UPDATE

:

, "form"

<form id="frmChk">
    <div id="listView" class="k-listview" >
    </div>
</form>

input same name

<script type="text/x-kendo-tmpl" id="myTemplate">
    <div class="item click"  data="${ProductID}">
        <input type="checkbox" name="chkValue" value="${ProductID}"  class="click" />
        <span class="checkbox">#:ProductName#</span>
    </div>
</script>

Go , jeryery serialize:

<script>
    function getCheckedBoxValue()
    {
        $("#frmChk").serialize(); 
    }
</script>

:

<input type="checkbox" name="chkValue" value="Ikura1" class="click" />
<input type="checkbox" name="chkValue" value="Ikura2" class="click" />
<input type="checkbox" name="chkValue" value="Ikura3" class="click" />

getCheckedBoxValue, :

chkValue=Ikura1,Ikura2,Ikura3
+4

Source: https://habr.com/ru/post/1626084/


All Articles