This is a migrated thread and some comments may be shown as answers.

Iterate items array

1 Answer 217 Views
Toolbar
This is a migrated thread and some comments may be shown as answers.
CHRISTOPHER
Top achievements
Rank 1
Iron
CHRISTOPHER asked on 12 Nov 2020, 06:18 PM

I have code that adds buttons to a kendoToolBar.  Upon completion, the button is added but the .items array still says null or undefined.  The basic gist I am ultimately after is how to iterate through the buttons/controls in a toolbar and delete them all or at least delete them one by one by id.  But, I can't figure out the syntax for iterating this array.  Can anyone point out what I'm doing wrong?

 

        var toolbar = $("#tbrMyToolBar").data("kendoToolBar");
 
        toolbar.add(
            { 
                type: "button",
                attributes: { "class": "k-button" },
                text: name, 
                id: "testbutton", 
                togglable: false,
                click: function(e)
                {
                    
                }
            });

         console.log(toolbar.items.length);

1 Answer, 1 is accepted

Sort by
0
Stoyan
Telerik team
answered on 13 Nov 2020, 03:31 PM

Hello, Christopher,

thank you for your question.

To access the items you can use toolbar.options.items It exposes the array of items with which the Toolbar was initialized. Then you can use the remove method exposed by the ToolBar API.

Here is my code sample: https://dojo.telerik.com/@Stoyan/AGUMaQeP

Please don't hesitate to reach out should more questions arise.

Regards,
Stoyan
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Toolbar
Asked by
CHRISTOPHER
Top achievements
Rank 1
Iron
Answers by
Stoyan
Telerik team
Share this question
or