<ejs-daterangepicker id="date" change="onChange"></ejs-daterangepicker>
<script>
function onChange(args) {
console.log(args.event.target);
}
</script> |
<ejs-daterangepicker id="presets" format="dd MMM yyyy" placeholder="Choose a Range" startDate="ViewBag.StartDate" endDate="ViewBag.EndDate" change="onChange">
<e-daterangepicker-presets>
<e-daterangepicker-preset id="week" label="This Week" start="ViewBag.weekStart" end="ViewBag.weekEnd"></e-daterangepicker-preset>
<e-daterangepicker-preset id="month" label="This Month" start="ViewBag.monthStart" end="ViewBag.monthEnd"></e-daterangepicker-preset>
<e-daterangepicker-preset id="lastmonth" label="Last Month" start="ViewBag.lastMonthStart" end="ViewBag.lastMonthEnd"></e-daterangepicker-preset>
<e-daterangepicker-preset id="year" label="Last Year" start="ViewBag.lastYearStart" end="ViewBag.lastYearEnd"></e-daterangepicker-preset>
</e-daterangepicker-presets>
</ejs-daterangepicker>
<script>
function onChange(args) {
console.log("Change event triggered");
}
</script> |
public IActionResult Index()
{
int days = (int)DateTime.Now.DayOfWeek;
DateTime lastMonth = DateTime.Now.AddMonths(-1);
ViewBag.weekStart = DateTime.Now.AddDays(-days);
ViewBag.weekEnd = ViewBag.weekStart.AddDays(6);
ViewBag.monthStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
ViewBag.monthEnd = ViewBag.monthStart.AddMonths(1).AddDays(-1);
ViewBag.lastMonthStart = new DateTime(lastMonth.Year, lastMonth.Month, 1);
ViewBag.lastMonthEnd = ViewBag.lastMonthStart.AddMonths(1).AddDays(-1);
ViewBag.lastYearStart = new DateTime(DateTime.Now.Year - 1, 1, 1);
ViewBag.lastYearEnd = new DateTime(DateTime.Now.Year - 1, 12, 31);
ViewBag.StartDate = new DateTime(2021, 02, 20);
ViewBag.EndDate = new DateTime(2021, 05, 21, 23, 59, 59);
return View();
}
|
public IActionResult Index()
{
int days = (int)DateTime.Now.DayOfWeek;
DateTime lastMonth = DateTime.Now.AddMonths(-1);
ViewBag.weekStart = DateTime.Now.AddDays(-days);
ViewBag.weekEnd = ViewBag.weekStart.AddDays(6);
ViewBag.monthStart = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
ViewBag.monthEnd = ViewBag.monthStart.AddMonths(1).AddDays(-1);
ViewBag.lastMonthStart = new DateTime(lastMonth.Year, lastMonth.Month, 1);
ViewBag.lastMonthEnd = ViewBag.lastMonthStart.AddMonths(1).AddDays(-1);
ViewBag.lastYearStart = new DateTime(DateTime.Now.Year - 1, 1, 1);
ViewBag.lastYearEnd = new DateTime(DateTime.Now.Year - 1, 12, 31);
ViewBag.StartDate = new DateTime(2021, 02, 20);
ViewBag.EndDate = new DateTime(2021, 05, 21);
return View();
}
|