Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Calendar Entries from JSON response

    Hi, Im trying to do what I thought would be a simple calendar with entries sourcing from a page outputting them in a JSON format. From the examples and everything Ive searched, I thought I had it right but apparently Im still missing something.

    Im using SmartGWT ver 2.4, my JSON is coming from a PHP page and Ive verified the formatting is correct by looking at Firebug (I see the JSON response).

    Code:
    final DataSource calendarDS = new DataSource();
    calendarDS.setDataFormat(DSDataFormat.JSON);
    calendarDS.setDataURL("entries.php");
    		
    DataSourceIntegerField taskId = new DataSourceIntegerField("task_id","eventId");
    taskId.setPrimaryKey(true);
    DataSourceTextField nameField = new DataSourceTextField("person_id","name");
    DataSourceTextField descField = new DataSourceTextField("description","description");
    DataSourceDateTimeField startTime = new DataSourceDateTimeField("plan_start_dttm","startTime");
    DataSourceDateTimeField endTime = new DataSourceDateTimeField("plan_end_dttm","endTime");
    
    		
    		
    		calendarDS.setFields(taskId,nameField,descField,startTime,endTime);
    
    
    
    Calendar calendar = new Calendar();
    calendar.setDataSource(calendarDS);
    calendar.setAutoFetchData(true);
    The column names coming from the JSON output are the first entry in each text field. I used the the second title field as the names for the calendar entry, but not sure if this is even right.

    When I access the page I can see the request made to entries.php and see the proper response, but dont get any calendar entries; just the calendar itself.

    Ive also thought about overriding the transformResponse using a restdatasource, but based on other examples, it seems like I dont need to do that unless Im modifying the results in the json object.

    The date/time entries are in the following format, could this be causing them to not be entered?

    2011-10-11 13:30:00.000

    Sorry if I seem a bit scatterbrained, been digging into this for hours and just cant seem to get it right. Thanks in advance!

    #2
    Originally posted by tpabrad
    The column names coming from the JSON output are the first entry in each text field. I used the the second title field as the names for the calendar entry, but not sure if this is even right.
    I'm pretty sure this is wrong. The second title field is what is displayed to the user. You want to use "setEndDateField" and the other similar methods.

    Comment

    Working...
    X