Adjusting functionality of Dojox Calendar Widget

2019-09-01 09:48发布

问题:

I'm looking into using the Dojox calendar widget.

I need to make a few adjustments to the default configurations and am having issues finding the information in the documentation.

I need to remove all of the buttons in the navigation bar at the top of the calendar i.e. Today, Day, 4 Days, Week, Month.

I suspect I need to subclass the Calendar component and override some functions?

I also need to use the sub columns feature to add multiple calendars.

I am brand new to Dojo and would appreciate any help and advice on the most appropriate way to approach this.....concrete examples would be great.

My exisiting code to setup calendar:

require([ "dojo/parser", "dojo/ready", "dojox/calendar/Calendar" ], function(
        parser, ready, Calendar) {
    ready(function() {

        calendar = new Calendar({           
            dateInterval : "day",
            style : "position:relative;height:600px;",
            selectionMode: "none",
        }, "confCalendar");
    })
})

Thanks

回答1:

It's been sometime, but I figure this can be useful to anyone having this same issue.

I came across the same situation where I had to remove some of the navigation buttons from the top of the calendar.

The solution? Go into dojox/calendar/Calendar.js. You will find that the 2nd line has this code: {cache:{"url:dojox/calendar/templates/Calendar.html":"<div>\n\t<div data-dojo-atta.... if you follow the line, you will see that what you have after the colon is the template used to create the calendar. If you want to remove navigation buttons (say, the "Month" button), just erase the button for the template (for month, you will need to erase <button data-dojo-attach-point=\"monthButton\" data-dojo-type=\"dijit.form.Button\" >Month</button>.

Hope it helps anyone in need!



回答2:

If you need to remove the buttons that's maybe because you want to display a single type of view? (i.e. always a Day or Week view?). In this case you might better directly use the type of view you want instead of customizing calendar? Like using dojox/calendar/ColumnView? You should find examples of this in dojox/calendar/tests/columnview.html.

If you really need/want to modify Calendar I suggest you copy/paste the template of it (dojox/calendar/templates/Calendar.html) and remove in there what you don't need.



标签: calendar dojo