2015-12-08 1 views
0

Je suis en train de faire un calendrier scolaire dans mon application, alors j'ai pensé pouvoir utiliser le widget calendrier gwt et le personnaliser (Ajouter un professeur, des infos sur la classe, etc.). Par exemple, comme ceci http://www.smartclient.com/smartgwt/showcase/#custom_editing_calendar_category
Mais comment puis-je utiliser DataSource pour les champs supplémentaires?
calendar.setEventEditorFields - n'accepte pas DataSourceSmart GWT Personnaliser le calendrier

Aussi, si vous connaissez un peu mieux widget de pour cet objectif, il sera agréable de me dire plus.

L'exemple est de vitrine SmartGWT avec la différence que j'essaie de prolonger CalendarEvent je peux avoir pour exemple nouveau champ « professeur »

Cest le plase où nous essayons de construire le calendrier et essayer d'ajouter une nouvelle champ dans la source de données.

package GwtApp.TechnicalUniversityApp.client.Schedule.Vertical; 

import com.smartgwt.client.data.DataSource; 
import com.smartgwt.client.data.fields.DataSourceDateTimeField; 
import com.smartgwt.client.data.fields.DataSourceSequenceField; 
import com.smartgwt.client.data.fields.DataSourceTextField; 
import com.smartgwt.client.widgets.Canvas; 
import com.smartgwt.client.widgets.calendar.Calendar; 

public class ScheduleLayoutVertical { 

    public static Canvas buildScheduleLayout(){ 
     DataSource eventDS = new DataSource(); 
     DataSourceSequenceField eventIdField = new DataSourceSequenceField("eventId"); 
     eventIdField.setPrimaryKey(true); 

     DataSourceTextField nameField = new DataSourceTextField("name"); 
     DataSourceTextField descField = new DataSourceTextField("description"); 
     DataSourceDateTimeField startDateField = new DataSourceDateTimeField("startDate"); 
     DataSourceDateTimeField endDateField = new DataSourceDateTimeField("endDate"); 
     DataSourceTextField professorField = new DataSourceTextField("professor"); 

     eventDS.setFields(eventIdField, nameField, descField, startDateField, endDateField,professorField); 
     eventDS.setClientOnly(true); 

     eventDS.setTestData(CalendarData.getRecords()); 

     Calendar calendar = new Calendar(); 
     calendar.setDataSource(eventDS); 
     calendar.setAutoFetchData(true); 


     return calendar; 
    } 
} 

Cest le plase où nous remplissons les données et utiliser le CalendarEvent étendu

package GwtApp.TechnicalUniversityApp.client.Schedule.Vertical; 

import java.util.Date; 

public class CalendarData { 
    private static CalendarEvent[] records; 
    private static Date today = new Date(); 
    private static int year = today.getYear(); 
    private static int month = today.getMonth(); 
    private static int start = today.getDate() - today.getDay(); 

    public static CalendarEvent[] getRecords() { 
     if (records == null) { 
      records = getNewRecords(); 
     } 
     return records; 
    } 

    public static CalendarEvent[] getNewRecords() { 
     return new CalendarEvent[]{ 
       new CalendarEvent(1, "Meeting", "Shareholders meeting: monthly forecast report", new Date(year, month, start + 2, 9, 0, 0), new Date(year, month, start + 2, 14, 0, 0),"TestProff1"), 
       new CalendarEvent(2, "Realtor", "Breakfast with realtor to discuss moving plans", new Date(year, month, start + 3, 8, 0, 0), new Date(year, month, start + 3, 10, 0, 0),"TestProff2"), 
       new CalendarEvent(3, "Soccer", "Little league soccer finals", new Date(year, month, start + 4, 13, 0, 0), new Date(year, month, start + 4, 16, 0, 0),"TestProff1"), 
       new CalendarEvent(4, "Sleep", "Catch up on sleep", new Date(year, month, start + 4, 5, 0, 0), new Date(year, month, start + 4, 9, 0, 0),"TestProff2"), 
       new CalendarEvent(5, "Inspection", "Home inspector coming", new Date(year, month, start + 4, 10, 0, 0), new Date(year, month, start + 4, 12, 0, 0), false, "testStyle"), 
       new CalendarEvent(6, "Airport run", "Pick James up from the airport", new Date(year, month, start + 4, 1, 0, 0), new Date(year, month, start + 4, 3, 0, 0),"TestProff1"), 
       new CalendarEvent(7, "Dinner Party", "Prepare elaborate meal for friends", new Date(year, month, start + 4, 17, 0, 0), new Date(year, month, start + 4, 20, 0, 0),"TestProff1"), 
       new CalendarEvent(8, "Poker", "Poker at Steve's house", new Date(year, month, start + 4, 21, 0, 0), new Date(year, month, start + 4, 23, 0, 0),"TestProff2"), 
       new CalendarEvent(9, "Meeting", "Board of directors meeting: discussion of next months strategy", new Date(year, month, start + 5, 11, 0, 0), new Date(year, month, start + 5, 15, 0, 0),"TestProff1") 
     }; 
    } 
} 

CalendarEvent avec le nouveau constructeur étendu

package GwtApp.TechnicalUniversityApp.client.Schedule.Vertical; 

import java.util.Date;

CalendarEvent public class étend com.smartgwt.client.widgets.calendar.CalendarEvent {

String professor; 

public CalendarEvent(int i, String string, String string2, Date date, 
     Date date2, String string3) { 
    super(i, string, string2, date, date2); 
    setProfessor(string3); 
} 



public CalendarEvent(int i, String string, String string2, Date date, 
     Date date2, boolean b, String string3) { 
    super(i, string, string2, date, date2, b); 
    setProfessor(string3); 
} 



public String getProfessor() { 
    return getAttributeAsString("professor"); 
} 

public void setProfessor(String professor) { 
    setAttribute("professor", professor); 
} 

}

Répondre

0

Les champs supplémentaires (personnalisés) doivent appartenir au calendrier DataSource.

+0

Merci pour votre réponse, j'ai essayé exactement cela (nouvelle édition de post-source) mais je ne trouve pas un moyen de visualiser le nouveau champ. – nasdaq