0

ZK Calender Demo

asked 2015-02-21 06:31:46 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2611 3 8
http://emrpms.blogspot.in...

Is any ZK Calender MVVM Example is available ?

delete flag offensive retag edit

5 Answers

Sort by ยป oldest newest most voted
1

answered 2015-02-24 06:10:24 +0800

cor3000 gravatar image cor3000
4332 1 7
ZK Team

In MVVM you keep the state of the UI in your ViewModel. Instead of calling component methods you need to control the component properties.

In this case you have to bind the "currentDate" property, and adjust it according to your requirements:

<calendars currentDate="@load(vm.firstDayInView)" .../>
<button onClick="@command('gotoNext')" .../>

in your VM

Date firstDayInView = new Date(); //today

@Command("gotoNext")
@NotifyChange("firstDayInView")
public void gotoNext() {
   //some pseudo code it is up to you to adjust the date...
  if(isMonthView) --> firstDayInView + 1 Month
  if(isWeekView) --> firstDayInView + 7 Days
  if(isDayView) --> firstDayInView + 1 Day
}
link publish delete flag offensive edit
1

answered 2015-02-24 02:55:22 +0800

cor3000 gravatar image cor3000
4332 1 7
ZK Team

there is no difference in the MVVM usage with ZK Calendar. As usual you'll implement your CalendarModel or extend SimpleCalendarModel and make it available through a getter in your VM class.

Then you can refer to it using the MVVM annotations also no difference here.

<calendars firstDayOfWeek="@load(vm.firstDayOfWeek)" 
    height="600px" timeZone="Main=GMT+0" 
    mold="@load(vm.currentView)"
    model="@init(vm.myCalendarModel)" onEventCreate="@command('createEvent', event=event)" />

As you see there is nothing special here. The MVVM pattern can be applied in many scenarios even if there is no specific example. How you react to those commands, and what kind of UI you display to create or update a calendar event is up to you and outside the scope of the ZK-Calendar component, which just provides a view of your Events in your CalendarsModel, and has some events you have to handle by yourself.

link publish delete flag offensive edit
0

answered 2015-02-21 17:53:47 +0800

Darksu gravatar image Darksu
1991 1 4

Hello Senthilchettyin,

I searched the internet and could not find any MVVM examples.

Perhaps it is good time to create one.

Best Regards,

Darksu

link publish delete flag offensive edit
0

answered 2015-02-24 04:11:21 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2611 3 8
http://emrpms.blogspot.in...

Thanks Robert.

But how we can handle the other Command such as Goto Previous , and next page as shown the ZK DEMO

Currently I am mixing MVVM and MVC as shown here.

    @Wire("#calendars")
private Calendars calendarCtrl;


@Command
public void gotoNext() {
    calendarCtrl.nextPage();
}

@Command
public void gotoPrev() {
    calendarCtrl.previousPage();
}
link publish delete flag offensive edit
0

answered 2015-02-24 07:14:26 +0800

Senthilchettyin gravatar image Senthilchettyin flag of India
2611 3 8
http://emrpms.blogspot.in...

Thank you Robert.

But why selectedItem Property not available for Calender component ? I know that i can handle this indirectly on the Event onEventEdit, but if it will add more value for MVVM in calender Component .

link publish delete flag offensive edit

Comments

there is no selectedItem because it is not needed... you have all information in the CalendarsEvent, if you ask me I'd remove the selectedItem also from other components Listbob/Combobox... and only handle the selection via Selectable interface

cor3000 ( 2015-02-24 07:38:19 +0800 )edit

Just for Argument, i am curious to know if you remove selectedItem for Listbox, how we can get the currently user selected Item ?

Senthilchettyin ( 2015-02-24 07:55:43 +0800 )edit

I don't think it's going to get removed, for backwards compatibility. but still I don't like multiple methods for the same purpose resulting in having to synchronize the state.

cor3000 ( 2015-02-24 08:46:33 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2015-02-21 06:31:46 +0800

Seen: 24 times

Last updated: Feb 24 '15

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More