GWT Calendar or Datepicker to display seasons in a year - gwt

I'm trying to find the best component to display date ranges among a year.
An idea is to display are months as boxes (12 boxes) and paint the seasons with a different colour.
GWT Datepicker does not really fit my needs since is not extendible enough (http://code.google.com/p/google-web-toolkit/issues/detail?id=3848). A calendar component is too much complicated. GXT datepicker lacks of extendibility too.
That's a sample of what I'd like to acheive:
Any idea? I'm using GXT as library.

In my opinion, using DatePicker isn't such a bad idea. Here's a little example that covers a single month. I think it won't be too hard to extend this to a full year by arranging 12 of these in a grid:
Java
final DateTimeFormat format = DateTimeFormat.getFormat("yyyy-MM-dd");
final DatePicker datePicker = new DatePicker();
datePicker.setCurrentMonth(format.parse("2012-01-01"));
datePicker.addStyleName("my-cal");
final Date start = format.parse("2012-01-17");
final Date end = format.parse("2012-01-28");
for (final Date date = start; date.compareTo(end) <= 0; CalendarUtil
.addDaysToDate(date, 1)) {
datePicker.addStyleToDates("my-green", date);
}
CSS
.my-green { background-color: green !important; }
.my-cal .datePickerPreviousButton { visibility: hidden; }
.my-cal .datePickerNextButton { visibility: hidden; }
With the "clean" theme, it looks like this:
P. S. Here's how the full calendar could look like:
Full code:
http://pastebin.com/xkrRQQht

Related

In echarts.js, line chart, how to make xAxis show months when I only have the data of every date?

In line charts, I want to show month names on xAxis and every month shows its data by date.
I've tried multi xAxis and it's not working well, or maybe use formatter?
Did you try the axisLable formatter? You can call a function there to do the formatting.
xAxis: {
axisLabel: {
formatter: (function(value){
return moment(value).format('MMM-YY');
})
}
}
Hope this will help.

How do I create a dual date entry in Angular 2 with Kendo UI?

I'm trying to create a dual date object in Angular2 and I have no idea how it can be accomplished.
What I mean by a dual date object is basically creating a single instance of a date picker using Kendo UI (screenshot of a date picker from Kendo UI). Once it's clicked, two instances of the date object appears. The first is for 'Start date' and the second is for 'End Date'. The date object uses Kendo UI.
Basically it's for users to select a date range. I would really appreciate any help on this. Thank you.
The Kendo UI DatePicker can work with one date only. For selecting a date range, use two widget instances.
http://demos.telerik.com/kendo-ui/datepicker/rangeselection
It is theoretically possible to use a Kendo UI Popup with two Calendar instances inside, and store the two date values somewhere, according to your preferences.
<style>
#popup > div {display: inline-block; }
#textbox { width: 300px; }
</style>
<p>Focus the textbox:</p>
<input id="textbox" class="k-textbox" />
<div id="popup">
<div id="calendar1"></div>
<div id="calendar2"></div>
</div>
<script>
var textbox = $("#textbox");
$("#popup").kendoPopup({
anchor: textbox
});
$("#calendar1").kendoCalendar({
change: updateTextBox
});
$("#calendar2").kendoCalendar({
change: updateTextBox
});
textbox.focus(function(){
$("#popup").data("kendoPopup").open();
});
function updateTextBox() {
textbox.val("use the Calendars' value method here");
}
</script>

kendo datepicker depth year last day

I am trying to initialize a Kendo "datepicker" with the following options:
$("#elementid").kendoDatePicker({
//...
depth: "year"
});
When I change month in the widget I would like to set in my view model the last day of the selected month (not, as by default, the first one).
For instance: by selecting "January" the datepicker is set on "01/01/2013", but I would like it to return "31/01/2013" (the last day).
Does somebody know how can i do it?
Define you kendoDatePicker as:
$("#elementid").kendoDatePicker({
...
depth : "year",
change: function (e) {
var val = this.value();
this.value(new Date(val.setMonth(val.getMonth() + 1, 0)));
}
});
We handle the change event and use JavaScript for calculating the last day of the chosen date.

DatePickers on the FloatPanel

I need to place several DatePicker widgets into the row. If there is not enough width to place all of them the rest widgets shift to the next row. It is the default HTML layout behavior. So I am trying to use FlowPanel. With any other widgets (Buttons, Labels, ...) everything ok, but DatePickers are placed one widget to the row. Here's the code
FlowPanel panel = new FlowPanel();
DatePicker picker1 = new DatePicker();
DatePicker picker2 = new DatePicker();
panel.add(picker1);
panel.add(picker2);
RootPanel.get().add(panel);
Any suggestions to solve this problem?
Thanks.
DatePicker's root element is a table so you'd have to give it a display: inline-table style, or put it in an element with display: inline-block style.
The following shouldn't break any other use of DatePicker, but won't work in IE 6 or 7; it's the Simplest Thing That Could Possibly Work™:
.gwt-DatePicker { display: inline-table; }
If you really need IE 6/7 support, you could try the following, in a CssResource:
#if user.agent ie6 {
.gwt-DatePicker { display: inline; }
}
#else {
.gwt-DatePicker { display: inline-table; }
}

How to control style of today's cell in asp.net ajax CalendarExtender?

Based on the AjaxControlToolkit API for the CalendarExtender I can control the style of the selected date using:
.ajax__calendar_active { background-color:red }
And according to the API, I was hoping, that .ajax__calendar_today would allow me to control the style of today's table cell, if show. Unfortunately, this .ajax__calendar_today controls the style of the bigger "Today: XYZ" button at the bottom of the calendar.
Does anyone know how to style today's table cell, if/when displayed?
Update:
I inspected the HTML using Firebug and see that there is no special css class or other indicator for today's day cell. I guess that makes sense from a server side perspective... how to know what day it is on the user's machine, without adding code to capture GMT offset and such.
So know I think that i am stuck creating some javascript to get today's date client side and comparing to each cell's title attribute, which is set to something like "Friday, February 11, 2011".
Update:Sept 2011
The latest AjaxControlToolkit release has added the .ajax__calendar_today css class to control this.
I believe you could use the following CSS class:
.ajax__calendar_today .ajax__calendar_day { background-color:red;}
Couldn't find a special class for this, so I wound up putting a style in my site.master.
FYI, the padding 0 is because the border takes 2px, which is what default padding is set for.
<style type="text/css">
div.ajax__calendar_day[title='<%=DateTime.Now.ToString("dddd, MMMM dd, yyyy")%>']
{
border: 1px solid #F00;
padding-right: 0px;
}
</style>
The best solution I found is this post.
I just removed the first 2 lines of the function (set current day) and fixed typo error in dayDIVs[i].style.bordercolor to dayDIVs[i].style.borderColor (uppercase C for color). You can also add dayDIVs[i].style.borderStyle = "dotted";
So here is the transcript of it (with my modifications):
/* In HEAD section */
<script type="text/javascript">
function clientShown(sender, args) {
var today = new Date();
var currentTitle = today.localeFormat("D");
//Find all the Day DIVs in the Calendar's daysBody
var dayDIVs = sender._daysBody.getElementsByTagName("DIV");
for (i = 0; i < dayDIVs.length; i++) {
if (dayDIVs[i].title == currentTitle) {
//Change the current day's style
dayDIVs[i].style.borderColor = "#0066cc";
dayDIVs[i].style.borderStyle = "dotted";
}
}
}
</script>
/* and then in your BODY: */
<cc1:CalendarExtender ID="CE" runat="server" Enabled="True" TargetControlID="CalendarDateTextBox"
OnClientShown="clientShown" />
You need the following css class:
.ajax_calendar .ajax_calendar_active .ajax__calendar_day {background-color:red;}