Results 1 to 4 of 4

Thread: How do I create a new button on the Calendar toolbar

  1. #1
    SteveCOM is offline Junior Member
    Join Date
    Oct 2011
    Rep Power

    Default How do I create a new button on the Calendar toolbar

    I am new to Zimlet creation however I found the code sample to place a button on the Mail Tab toolbar. What I do not know or understand is what I would need to change it to place one on the calendar tab toolbar next to the View pull down.

    Can someone please provide an example?

    Sample of button on the Mail tab toolbar

    com_zimbra_example_toolbarhook_HandlerObject = function() {
    com_zimbra_example_toolbarhook_HandlerObject.prototype = new ZmZimletBase;
    com_zimbra_example_toolbarhook_HandlerObject.prototype.constructor = com_zimbra_example_toolbarhook_HandlerObject;
     * This method gets called by the Zimlet framework when a toolbar is created.
    com_zimbra_example_toolbarhook_HandlerObject.prototype.initializeToolbar =
    function(app, toolbar, controller, viewId) {
        if (viewId == ZmId.VIEW_CONVLIST || viewId == ZmId.VIEW_TRAD) {
            // get the index of "View" menu so we can display the button after that
            var buttonIndex = 0;
            for (var i = 0; i < toolbar.opList.length; i++) {
                    if (toolbar.opList[i] == ZmOperation.VIEW_MENU) {
                            buttonIndex = i + 1;
            var buttonParams = {
                    text    : "Button",
                    tooltip: "Test Button",
                    index: buttonIndex, // position of the button
                    image: "zimbraicon" // icon
            // creates the button with an id and params containing the button details
            var button = toolbar.createOp("HELLOTEST_ZIMLET_TOOLBAR_BUTTON", buttonParams);
            button.addSelectionListener(new AjxListener(this, this._showSelectedMail, controller));   
     * Shows the selected mail.
    com_zimbra_example_toolbarhook_HandlerObject.prototype._showSelectedMail =
    function(controller) {
    	var message = controller.getMsg();
    	appCtxt.getAppController().setStatusMsg("Subject:"+ message.subject);

  2. #2
    reisinger is offline Trained Alumni
    Join Date
    Apr 2011
    Brazil/Sao Paulo
    Rep Power



    Sadly I'm not here to provide a solution, but I also want to know how to create a toolbar beside on the mail view. But, on my case, I need to put it on the contact list view. To help us, can someone provide a solution, considering not only the calendar and contact view, but any view? Maybe we should put it on the wiki for future reference!

  3. #3
    thomas.cook is offline New Member
    Join Date
    Nov 2012
    Rep Power


    To create button on calendar toolbar, add one more if condition in initializeToolbar method like this:

    if(view == "CLD" || view == "CLWW" || view == "CLM" || view == "CLW" || view == "CLL" || view == "CLS" || view == "CAL") {
    var buttonArgs = {
    text: "buttonText",
    tooltip: "Button Text",
    index: buttonIndex
    image: "tabIcon"
    var button = toolbar.createOp("buttonID", buttonArgs);
    button.addSelectionListener(new AjxListener(this, this._handleBtnClick, [controller, app]));

    You can do that for any view. All you need to do is get their viewId and put the if conditions like above in initializeToolbar method and you are done.

  4. #4
    ychaouche is offline Senior Member
    Join Date
    Jul 2012
    Rep Power


    Here are other examples : the code below shows how to add a button to the compose mail view, the create contact view and the create appt view.

    You have to implement the initializeToolbar function. This function is called by the framework anytime it shows a toolbar (I think). In this function, you test for what view you're in to create a button for the right toolbar. I prefer to define a function to create buttons, there's one for each but I only included createMailButton, otheres are very alike.

    Some views have the same ID suffixed by a number, that's why I have this toolbar.getButton() test in each if condition to check that the button haven't been created before (otherwise you'll find yourself with multiple identical buttons).

    Hope this helps.

    SugarBee.prototype.initializeToolbar = function(app, toolbar, controller, viewID){
    	if (!toolbar.getButton(SugarBee.addMailButtonID) && viewID.indexOf(ZmId.VIEW_COMPOSE) >= 0){
    	else if (!toolbar.getButton(SugarBee.addContactButtonID) && viewID == ZmId.VIEW_CONTACT){
    	else if (!toolbar.getButton(SugarBee.addApptButtonID) && viewID.indexOf(ZmId.VIEW_APPOINTMENT) >= 0){
    		_toolbar = toolbar;
    SugarBee.prototype._createMailButton = function (toolbar,controller){
        var args = {
    	text    : "Envoi+copie sugar",
    	tooltip : "Envoi l'e-mail et cr&eacute;e une copie dans SugarCRM",
    	image   : "plus",
    	index   : 1,
    	enabled : true
        var bouton = toolbar.createOp(SugarBee.addMailButtonID,args);
        bouton.addSelectionListener(new AjxListener(this._displayMessage,controller));
        SugarBee.addMailbuttonCreated = true;

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How do I create a single company wide calendar ?
    By qprcanada in forum Administrators
    Replies: 2
    Last Post: 01-31-2012, 02:49 PM
  2. Create Local Calendar Appointments
    By chads in forum General Questions
    Replies: 0
    Last Post: 12-19-2011, 08:32 AM
  3. Create calendar in Outlook?
    By mrmasse in forum Zimbra Connector for Outlook
    Replies: 1
    Last Post: 10-27-2011, 07:03 AM
  4. Replies: 3
    Last Post: 02-06-2008, 09:21 AM
  5. adding button to compose toolbar with a zimlet
    By sdouglass in forum Zimlets
    Replies: 1
    Last Post: 09-18-2006, 06:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts