Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Bug in 5p latest Nightly: TimeLine With dataSource founds not Data by ID

$
0
0
Hello,

I have some issues with timelines which are bound to a datasource. I am trying to read data from a JSON Restful. This seems to work... the appointments appear in the timetable (5 Dates with 1 day duration, see Screenshot).

My problems now are as follows:
1.The endDate does not appear correctly in the edit mask or in the mouseover text. The date format in the JSON Source is the same as the startDate, so it should be possible to read the endDate.

2. When I move a date to another day via drag&drop the date disappears in the timeline.

3. When I click on the "X" for removing an appointment... nothing happens on the first click... on the second cklick I am getting an error message which says "clientOnly remove operation failed: unable to find matching record" and on the developer console I get the following error:

Code:

13:50:01.788:TMR3:WARN:RPCManager:clientOnly remove operation failed: unable to find matching recordundefined - response: {status: -1,
data: "clientOnly remove operation failed: unab..."[66],
httpResponseCode: undef,
httpResponseText: undef,
transactionNum: 56,
clientContext: Obj,
internalClientContext: undef,
httpHeaders: undef,
context: Obj,
startRow: 0,
endRow: 0,
totalRows: 0}


Timeline Example Code:
Code:

private void initTimeLine()
    {
        Date startDate = getMinTourStartDate();
        CalendarUtil.addDaysToDate( startDate, -1 );

        Date endDate = getMaxTourEndDate();
        CalendarUtil.addDaysToDate( endDate, 1 );

        HeaderLevel headerDays = new HeaderLevel( TimeUnit.DAY );
        headerDays.setHeaderWidth( 120 );
        headerDays.setTitleFormatter( new HeaderLevelTitleCustomizer()
        {

            @Override
            public String getTitle( HeaderLevel headerLevel, Date startDate, Date endDate, String defaultValue,
                                    Calendar calendar )
            {
                DateTimeFormat fmt = DateTimeFormat.getFormat( "EEE,dd.MMM" );
                return fmt.format( startDate );
            }
        } );

        HeaderLevel[] headerLevels = new HeaderLevel[] { new HeaderLevel( TimeUnit.WEEK ), headerDays };

        calendar = new Timeline();
        calendar.setWidth100();
        calendar.setHeight100();

        CAssignedTimeLineShows dsClass = new CAssignedTimeLineShows();
        calendar.setDataSource( dsClass.getDataSource( mainWindow.getSelectedIDs() ) );
        calendar.setAutoFetchData( true );

        calendar.setCanEditLane( false );
        calendar.setShowEventDescriptions( false );
        calendar.setHeaderLevels( headerLevels );
        calendar.setLaneFields( new ListGridField[] { new ListGridField( "title", "Name", 300 ) } );
        calendar.setLanes( getLanes() );
        calendar.setEndDateField( CAssignedTimeLineShows.endDate );
        calendar.setStartDateField( CAssignedTimeLineShows.startDate );
        calendar.setStartDate( startDate );
        calendar.setEndDate( endDate );
        calendar.setDisableWeekends( false );
    }

    private Lane[] getLanes()
    {
        ListGridRecord[] records = mainWindow.getSelectedRecords();
        Lane[] lanes = new Lane[records.length];

        for ( int i = 0; i < records.length; i++ )
        {
            String id = records[i].getAttribute( CItemSupplyTours.tour_id );
            String startDate =
                DateTimeFormat.getFormat( "dd.MM.yyyy" ).format( records[i].getAttributeAsDate( CItemSupplyTours.start_date ) );
            String endDate =
                DateTimeFormat.getFormat( "dd.MM.yyyy" ).format( records[i].getAttributeAsDate( CItemSupplyTours.end_date ) );

            String name =
                records[i].getAttribute( CItemSupplyTours.name ) + "<br>"
                    + records[i].getAttribute( CItemSupplyTours.artist_names ) + "<br>" + startDate + " - " + endDate;

            lanes[i] = new Lane( id, name );
        }

        return lanes;
    }

DataSource example code
Code:

import java.util.Date;

import com.google.gwt.core.client.GWT;
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.types.DSDataFormat;

public class CAssignedTimeLineShows
{
    static String eventId = "eventId";
    static String name = "name";
    static String description = "description";
    static String startDate = "startDate";
    static String endDate = "endDate";
    static String lane = "lane";

    public DataSource getDataSource( String idValues )
    {
        DataSource ds = new DataSource();
        String dataUrl = GWT.getHostPageBaseURL() + "rest/shows/getAllShowsOfMultipleTours/" + idValues;
     

        ds.setDataURL( dataUrl );
        ds.setClientOnly( true );
        ds.setID( "timeline" );
        ds.setDataFormat( DSDataFormat.JSON );

        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 laneField = new DataSourceTextField( lane );

        ds.setFields( eventIdField, nameField, descField, startDateField, endDateField, laneField );

        return ds;
    }

}

The data arrive in JSON as follows:
Code:

"eventId":3005,
"lane":"144",
"name":"Paris",
"description":"Main Room"
"startDate":"2017-07-01T00:00:00.000+02:00",
"endDate":"2017-07-02T00:00:00.000+02:00"


Attached Images
File Type: png Screen1.png (6.6 KB)

Viewing all articles
Browse latest Browse all 4756

Trending Articles