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-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Is any ZK Calender MVVM Example is available ?
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
}
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 .
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 )editThanks 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();
}
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.
Asked: 2015-02-21 06:31:46 +0800
Seen: 24 times
Last updated: Feb 24 '15