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

Insert new button dynamically

1 Answer 81 Views
Toolbar
This is a migrated thread and some comments may be shown as answers.
LQKerry
Top achievements
Rank 1
LQKerry asked on 15 Jan 2020, 10:00 PM

I have been trying to find a way to insert a button into a Kendo ToolBar widget dynamically. I would like to insert it into a specific location among existing buttons on the ToolBar. The only functionality I see is an add function that will add a new button, but no way to insert it anywhere.

In my search on this topic I found this older thread:

https://www.telerik.com/forums/insert-item-at-the-beginning

which resulted in this feature request:

https://feedback.telerik.com/kendo-jquery-ui/1359920-kendotoolbar-dynamically-insert-items-insertafter-insertbefore

 

I am hoping that I am not the only one that has had a similar need. Is there any other way to be able to insert a new button?

Thanks in advance.

Kerry

1 Answer, 1 is accepted

Sort by
0
Petar
Telerik team
answered on 17 Jan 2020, 12:08 PM

Hi Kerry,

The desired functionality described in the linked Feature request is still not implemented in the ToolBar component. I cannot say when this request will be implemented as each feature request implementation depends on the community interest on it and our priority queue. What you can do is to vote for the linked feedback portal item. The more votes a given request has, the bigger the chance for its sooner implementation is. 

What I can suggest as a workaround for achieving the desired functionality is destroying the Toolbar and re-initialize it with new items every time a new element needs to be added to a specific position. Here is a Dojo project demonstrating the described functionality

var toolbar = $("#toolbar").data("kendoToolBar");
toolbar.destroy();

$("#toolbar").empty();
$("#toolbar").kendoToolBar({
      items: changedItems
}) 

Something I want to note is the marked in yellow line in the above snippet. Once the ToolBar is destroyed we have to clear the content inside the div element used for the toolbar initialization.

Regards,
Petar
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Toolbar
Asked by
LQKerry
Top achievements
Rank 1
Answers by
Petar
Telerik team
Share this question
or