Search code examples
sapui5

How to set default selected dates for Calendar Control in SAPUI5


How to have default dates selected from odata for the calendar control. I tried a jsbin. it says the default aggregation need to filled before adding child.

<u:Calendar id="calendar" select="handleCalendarSelect" singleSelection="false" selectedDates="{path:'/selectedDates'>
            <u:DateRange startDate="{startDate}"/>
            </u:Calendar>

https://jsbin.com/yurikay/edit?html,output


Solution

  • You omitted aggregation tag <u:selectedDates>

      <u:Calendar
                id="calendar"
                selectedDates="{path: '/selectedDates'}"
                singleSelection="false"
                select="handleCalendarSelect" >
                  <u:selectedDates>
                    <u:DateRange startDate="{startDate}" />
                  </u:selectedDates>
                </u:Calendar>
    

    Working example: https://jsbin.com/zupecihiye/1/edit?html