Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
智能GWT自定义日历_Gwt_Calendar_Widget_Customization_Smartgwt - Fatal编程技术网

智能GWT自定义日历

智能GWT自定义日历,gwt,calendar,widget,customization,smartgwt,Gwt,Calendar,Widget,Customization,Smartgwt,我正在我的应用程序中查看一些学校时间表,所以我想我可以使用gwt日历小部件并自定义它(添加教授、一些班级信息等)。 比如像这样 但是,如何将数据源用于其他字段? 日历。setEventEditorFields-不接受数据源 此外,如果你知道一些更好的小部件为这个目标,这将是很高兴告诉我更多关于它 该示例来自smartgwt showcase,不同之处在于我尝试扩展CalendarEvent,因此我可以使用新字段“professor”作为示例 这就是我们试图构建日历并试图在数据源中添加新字段的地方

我正在我的应用程序中查看一些学校时间表,所以我想我可以使用gwt日历小部件并自定义它(添加教授、一些班级信息等)。 比如像这样
但是,如何将数据源用于其他字段?
日历。setEventEditorFields-不接受数据源

此外,如果你知道一些更好的小部件为这个目标,这将是很高兴告诉我更多关于它

该示例来自smartgwt showcase,不同之处在于我尝试扩展CalendarEvent,因此我可以使用新字段“professor”作为示例

这就是我们试图构建日历并试图在数据源中添加新字段的地方

    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;  
    }
}
这就是我们填充数据并使用扩展日历事件的位置

    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

package GwtApp.TechnicalUniversityApp.client.Schedule.Vertical;
导入java.util.Date

公共类CalendarEvent扩展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);
}

}

其他(自定义)字段必须属于日历数据源。

感谢您的回复,我已经尝试过了(新的post source编辑),但我找不到可视化新字段的方法。