I have an UltraCalendarCombo calendar control that I need to disable a set of dates in (weekends and public holidays basically).
I iterate through the list of dates for that month and set all the corresponding dates to disabled, this makes the current month look alright, but when I click the next month button on the control and try to access a month past now + 3 or 4 it jumps back to this month.
Has anyone any idea what this control is smoking, and where I can get some?
DateTimeCollection badDates = getMeSomeBadDatesmonth, year);
foreach (DateTime date in badDates)
{
myForm.CalendarInfo.DaysOfMonth[date.Day].Enabled = false;
}
Their controls have been going downhill for some time. I want to know what they are all smoking over there. I have been using their controls since the 2004 version of Net Advantage(which I really liked), but I have given up on using them on any new development. The bloat of features has broken what functionality did work and the documentation is just horrendous :(
Sorted it, the DaysOfMonth collection applies to a specific day (by number) of all months. For example, DaysOfMonth[10] applies to the tenth of every month of the year.
So I needed to use:
Infragistics.Win.UltraWinSchedule.Day theDay = _form.ValueDateCalInfo.GetDay(date, true);
if (theDay != null) theDay.Enabled = false;
Related
I am trying to implement a date-sorting method for a news list that works across browsers. However, the one method I have tried that works well, only works in Chrome:
origArt.sort(function(a, b) {
var dateA = new Date(a.date), dateB = new Date(b.date);
return dateB - dateA;
});
I also tried this code, suggested in other sorting questions as a possible solution:
origArt.sort(function(a,b){
return (b.date > a.date) ? 1 : (b.date < a.date) ? -1 : 0;
});
But, because the dates in my JSON vary from year; month & year; and month, year and day; the news list sorts in reverse
alphabetical order, not reverse chronological order.
They are strings such as: "2018.", "April 8, 2015.", and "September 2015."
Your problem is that those aren't valid date strings. From some quick testing, Chrome appears to be doing a bit of guesswork as to what you mean, but the other browsers aren't.
Chrome:
new Date("2018.")
// Mon Jan 01 2018 00:00:00 GMT-0800 (Pacific Standard Time)
Firefox:
new Date("2018.")
// Invalid Date
And since Invalid Date > Invalid Date is always false, it isn't sorting anything. It's not just a matter of removing the period either, since "September 2015" also works in Chrome but fails in Firefox.
Ideally, you should fix your JSON or whatever code it's being generated from to use parseable date strings. If that's not an option, you'll probably have to write a custom parsing function that handles all the possible formats you might get, or see if a library like Moment.js can handle it for you.
To avoid label of duplicate here's a brief summary of all what i did.
After spending hours of googling to calculate the difference between two dates I came across here and here where, i was convinced to use NodaTime to get difference in terms of years,months and days.My application needs accuracy to calculate pension.I used datetimepicker to get the date value from form and then i use Date.cs from here to extract the date in dd/mm/year and then insert it into database.To subtract the two dates using Period.Between(date1, date2, PeriodUnits.Years).Years how should i pass datetimepicker to it?
Here's what Jon Skeet said: "you can use LocalDateTime.FromDateTime and then use the Date property to get a LocalDate".
How should i get a complete rid of time while inserting in database as well as finding the difference while using datetimepicker instead of Datetime.
Update:
//Date of appointment
var d_app = LocalDateTime.FromDateTime(dateTimePicker1.Value).Date;
//Date of retirement
var d_ret = LocalDateTime.FromDateTime(dateTimePicker2.Value).Date;
var years=Period.Between(d_app,d_ret,PeriodUnits.Years).Years;
var months = Period.Between(d_app, d_ret, PeriodUnits.Months).Months;
var days = Period.Between(d_app, d_ret, PeriodUnits.Days).Days;
MessageBox.Show(years.ToString()+" years"+months.ToString()+"months "+days.ToString()+"days");
Giving the code datetimepicker1.value as 2/21/1990 (d_app) and datetimepicker2.value as 3/09/2015(d_ret) it returned 25 yrs 300months 9147
days.
What am i doing wrong?
You're performing three separate computations here. You only need one:
var appointment = LocalDateTime.FromDateTime(dateTimePicker1.Value).Date;
var retirement = LocalDateTime.FromDateTime(dateTimePicker2.Value).Date;
var difference = Period.Between(appointment, retirement);
MessageBox.Show(string.Format("{0} years {1} months {2} days",
difference.Years, difference.Months, difference.Days));
UPDATE 4/19/2012 12PM PST: Gotta eat crow on this one. The problem was not with Angular's databinding but with math errors in how I was calculating the dates. I wasn't properly taking into account the minutes and seconds in my time calculations. I was just subtracting the timestamps from each other expecting the hours to come out nicely.
I've gotten myself into trouble with AngularJS databinding in which my different inputs need to be reciprocally bound to each other.
The form needs to contain the following:
A start date (this is a given, not an input)
An input to add hours on to the start date
Two inputs with the result: 1) a date picker and 2) an hour picker
If you change any of the inputs, it should update the others. So, the following would be desirable results:
(with original date-time as April 19th at 10pm). User enters '1 hour'. The result date becomes April 19th and the result time becomes 11pm.
Building on the above example, the user changes the date input to April 20th. The 'hours' now become 25 hours.
I've placed set up watchers, using $scope.$watch on each of these variables:
$scope.$watch('hours', function (newHours, oldHours, scope) {
if (newHours) {
var newEndDate = new Date(scope.origDate),
offHours = newEndDate.getHours();
newEndDate.setHours(offHours + newHours);
scope.endDate = newEndDate;
scope.endHours = newEndDate.getHours();
}
});
$scope.$watch('endHours', function (newEndHours, oldEndHours, scope) {
if (newEndHours) {
var newEndDate = new Date(scope.endDate);
newEndDate.setHours(newEndHours);
scope.endDate = newEndDate;
}
});
$scope.$watch('endDate', function (newEndDate, oldEndDate, scope) {
if (newEndDate) {
scope.hours = (newEndDate - scope.origDate) / (1000 * 60 * 60);
}
});
Each of these works fine on their own, but in tandem they cause a big fat mess. From my understanding of Angular, it seems that they're creating a 'feedback loop.' Edit: To wit, model 'A' will be updated and trigger a change on model 'B'. Model 'B' will then trigger a change on model 'A'.
Now, is it possible to temporarily suspend data-binding so that I can just update the models without firing the watchers? In some other contexts I've worked in (UITableView on Cocao comes to mind), one can ask to "stop updates," make some changes to the model, and then "resume updates."
Is there anything like this in AngularJS? If not, what am I not getting here, and how could I set up my project to achieve the desired functionality?
Here's a plunkr of my example.
I want to provide a user the ability to select a month\year I was going to just use 2 listboxes but I say that the Silverlight calendar had a year mode, which displays the months of a year (not the months with all the days).
But when you click on a month it switches to displaying the days in the month selected (month mode).
I tried switching back to the year mode in the SelectedDatesChanged event. But realized that fires only after I select a specific day in a month (at which point it does switch back the the year mode).
So my questions:
- can I get the calendar to stay in the year mode?
- is there an event for the month selected?
- can I even get the month select?
thanks
There is a DisplayModeChanged event that can be used. I my case I needed the first date and the last date of the selected month ... the code below does what I needed.
private void CalendarDisplayModeChanged(object sender, CalendarModeChangedEventArgs e)
{
//control might be null at start up so check for null
//probably could hook up event in Loaded or constructor instead of xaml to prevent this
if (calendarInYearMode != null) {
//reset back to year mode
calendarInYearMode.DisplayMode = CalendarMode.Year;
if (calendarInYearMode.DisplayDate != DateTime.MinValue) {
var beginningOfMonthDate = calendarInYearMode.DisplayDate;
var endOfMonthDate = calendarInYearMode.DisplayDate.AddMonths(1).AddDays(-1);
}
}
}
I am using the AnyChart 8.1.0 resource Gantt (anychart.ganttResource()) to show and edit planned data (car reservations).
I can edit / move a reservation horizontally to change the time / period of a reservation and also drag the start and/or enddate. But I would like to move a reservation from one car (row) to another - very similar to moving a task from one person to another.
Is that possible - and how?
Thanks!
Roel
I'm having the same issue, and as far as I can see you can use
tree.listen("treeItemMove", function (e) {
// do your stuff
});
Unfortunally, I think this will only work, if you only have one reservation in each row. If you have more than one, all reservations will be moved.
So far I haven't found a solution to get one reservation and move it to another row. But I hope it may help you in the rigth direction..
EDIT:
I have contacted Anychart support and asked if there is a way to move one period from one (child-) row and create a new row under another parent?
Here is the answer:
the current version of AnyGantt 8.1.0 doesn't provide this feature as an out-of-the-box or even with the extra code.
But you can modify the dataTree from the code as you need. This provides full control under the data, but without mouse interactivity.
That's too bad. I can manipulate the tree - even one period, using this code to delete and add a period. You can update a period as well, code should be similar.
function deletePeriod( pItemId, pPeriodId ){
var item = treeData.search("id", pItemId);
var periods = item.get("periods")
var i = periods.findIndex(function(e){ return e.id == pPeriodId; });
periods.splice(i,1);
item.set('periods', periods);
treeData.addChildAt( item, treeData.indexOfChild(item) );
}
and
function addPeriod( pItemId, pPeriodId, start, end){
var period = {
"id": pPeriodId,
"start": start,
"end": end,
"name": "Whatever name you want"
};
var item = treeData.search("id", pItemId);
var periods = item.get("periods");
periods.push(period);
item.set('periods', periods);
treeData.addChildAt( item, treeData.indexOfChild(item) );
}