Selecting All Items with a button click function

7 posts, 1 answers
  1. Safak
    Safak avatar
    12 posts
    Member since:
    Jan 2012

    Posted 08 Aug 2012 Link to this post

    Hi,

    Is there a way to select all items in the listview?

    I am able to select a row with .select method:

    ListView.select();


    Thanks
    Safak
  2. Answer
    John DeVight
    John DeVight avatar
    209 posts
    Member since:
    Jan 2010

    Posted 09 Aug 2012 Link to this post

    Hi Safak,

    The .select function will take an array of items.  Here is an example of calling the .select function and passing in all the listview items in the listview dataBound event handler:

    var _listView = $("#listView").kendoListView({
        dataSource: dataSource,
        selectable: "multiple",
        template: kendo.template($("#template").html()),
        dataBound: function(e) {
            _listView.select(_listView.element.children());
        }
    }).data("kendoListView");

    Attached is a working example.

    Regards,

    John DeVight
  3. Kendo UI is VS 2017 Ready
  4. srinivas
    srinivas avatar
    21 posts
    Member since:
    May 2012

    Posted 10 Aug 2012 Link to this post

    Hi John DeVight,


    The post was useful.My question is how can i select multiple list views with out clicking ctrl button.
    I want to use list view.select() method. can i able to select the list view based on the index or id of
    the list view.Here i am getting the index and id on selecting the check box in the list view.
    Then i want to select the multiple list views on selecting the check box in each list view 
    Hope you will understand my question 




    Thanks and Regards,
    Srinivas
  5. Safak
    Safak avatar
    12 posts
    Member since:
    Jan 2012

    Posted 10 Aug 2012 Link to this post

    Hi John,

    Thank you very much for your answer. It worked well as you explained.




    Hi Srinivas,

    I'm using the below codes with databound trigger to select some items with a button click. I hope it will help...


    I have #ID for DIV in template:
    <script type="text/x-kendo-tmpl" id="template">
            <div class="product" id="${ProductID}">
                <img src="../../uploads/Products/56X84/${ImagePath}" alt="${Name} image" />
                <h3>${Name}</h3>
            </div>
        </script>

    function onDataBound(arg) {
     
                var getListView = $("#listView").data("kendoListView");
                     
                        var Selected = $("#selecteditems").val();
                                         
                        lines = SelectedItems .split(/\n/);
                        lines = jQuery.unique(lines);
                        lines.sort();
     
                            for(var i in lines) {
                                row = $("#listView").find("#" + lines[i]).eq(0);
                                getListView.select(row);
                            }                
                }

    Finally giving the product IDs in the textbox as HTML
    <textarea id="selecteditems" name="selecteditems" class="k-textbox">
    518080
    518081
    518082
    </textarea>
  6. srinivas
    srinivas avatar
    21 posts
    Member since:
    May 2012

    Posted 10 Aug 2012 Link to this post

    Hi safak,


    Thank you for the post.
    Is there any method to select the list view using the index or id of the listview.
    Like listview.select(1);



    Thanks and Regards,
    Srinivas
  7. Safak
    Safak avatar
    12 posts
    Member since:
    Jan 2012

    Posted 12 Aug 2012 Link to this post

    Hi srinivas,

    Yes, you can use ListView.select(row);

    Use div #id in your div:

    <div class="product" id="5">


    Define the row that will be selected:
    row = $("#listView").find("#5").eq(0);

    Select the item:
    ListView.select(row);

  8. srinivas
    srinivas avatar
    21 posts
    Member since:
    May 2012

    Posted 14 Aug 2012 Link to this post

    Hi safak,

    Thank you very much safak.The code worked perfectly.
    Now i am able to select the listview using index.




    Regards,
    Srinivas
Back to Top
Kendo UI is VS 2017 Ready