Announcement

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

    setTimelineRange bug

    Dear developers,
    since the version smartgwt-13. 0d_2020-12-20, the function calendar.setTimelineRange (currentDate); has stopped working as before.

    I changed the code of the basic example to the following
    Code:
    import java.util.Date;
    import java.util.LinkedHashMap;
    
    import com.smartgwt.client.widgets.Button;
    import com.smartgwt.client.widgets.calendar.*;
    import com.smartgwt.client.widgets.events.ClickEvent;
    import com.smartgwt.client.widgets.events.ClickHandler;
    import com.smartgwt.client.widgets.form.DynamicForm;
    import com.smartgwt.client.widgets.form.fields.SelectItem;
    import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
    import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
    import com.smartgwt.client.widgets.grid.ListGridField;
    import com.smartgwt.client.widgets.layout.HLayout;
    import com.smartgwt.client.widgets.layout.VLayout;
    import com.smartgwt.client.types.TimeUnit;
    import com.google.gwt.core.client.EntryPoint;
    
    public class TestBug implements EntryPoint {
        public Timeline calendar;  
        public Date currentDate;  
    
        public void onModuleLoad() {
            currentDate = new Date(116, 5, 11);
            VLayout layout = new VLayout();  
            layout.setWidth100();  
            layout.setHeight100();  
            layout.addMember(getToolBar());  
            layout.addMember(getTimeline());  
    
            layout.draw();  
        }
        public Timeline getTimeline () {  
            HeaderLevel[] headerLevels = new HeaderLevel[]{  
                new HeaderLevel(TimeUnit.WEEK),  
                new HeaderLevel(TimeUnit.DAY)  
            };  
    
            calendar = new Timeline();  
            calendar.setHeight(451);  
            calendar.setStartDate(new Date(116, 5, 2));  
            calendar.setEndDate(new Date(116, 5, 22));  
            calendar.setCanEditLane(true);  
            calendar.setShowEventDescriptions(false);  
            calendar.setEventSnapGap(60); // snap to 1 hour intervals  
            calendar.setLaneEventPadding(2); // add a little space around events  
            // set up the grid  
            calendar.setHeaderLevels(headerLevels);  
            calendar.setLanes(TimelineLaneData.getRecords());  
            calendar.setLaneFields(new ListGridField[]{ new ListGridField("title", "Developer", 120)});  
            calendar.setData(TimelineData.getRecords());  
    
            calendar.setResolution(headerLevels, TimeUnit.DAY, 5 * 7, null);
    
            return calendar;  
        }
    
        public HLayout getToolBar() {
            HLayout toolBar = new HLayout();
            toolBar.setHeight(30);
    
            LinkedHashMap <String, String> weeksMap = new LinkedHashMap <String, String>();
            for(Integer i = 1; i < 7; i++) {
                String is = i.toString();
                weeksMap.put(is, is + " weeks");
    
            }
    
            SelectItem selectWeeksCount = new SelectItem();
            selectWeeksCount.setName("selectWeeksCount");
            selectWeeksCount.setTitle("weeks count");
            selectWeeksCount.setWrapTitle(false);
            selectWeeksCount.setValueMap(weeksMap);
            selectWeeksCount.setValue("5");
            selectWeeksCount.addChangedHandler(new ChangedHandler() {
                @Override
                public void onChanged(ChangedEvent event) {
                    HeaderLevel dayLevel = new HeaderLevel(TimeUnit.DAY);
                    dayLevel.setHeaderWidth(50);
                    HeaderLevel[] headerLevels = new HeaderLevel[] {
                            new HeaderLevel(TimeUnit.WEEK),
                            dayLevel
                    };
                    calendar.setResolution(headerLevels, TimeUnit.DAY, Integer.parseInt((String) event.getValue()) * 7, null);
                }
            });
    
            DynamicForm selectWeeksForm = new DynamicForm();
            selectWeeksForm.setHeight(20);
            selectWeeksForm.setTitleSuffix("");
            selectWeeksForm.setItems(selectWeeksCount);
    
            toolBar.addMember(selectWeeksForm);
    
            Button button = new Button("to day");
            button.setID("toDay");
            button.setAutoFit(true);
            button.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    calendar.setTimelineRange(currentDate);
                }
            });
    
            toolBar.addMember(button);
    
            return toolBar;
        }
    }
    after clicking on the "to day" button, my TimeLine looks like this....
    Click image for larger version  Name:	TimeLine_Bug.jpg Views:	0 Size:	28.1 KB ID:	264889

    in the smartgwt-13.0d_2020-12-09 version, everything worked correctly

    #2
    We've made a change to address this regression - please retest with a build dated March 13 or later.

    Comment

    Working...
    X