Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

DatePicker in Grid - Wrong Element/Format?

Hello Everyone,

I´ve got a Javascript-DateObject ("/Date(1354665600000)/") accessible via OData-Binding.

In my XMLView I have implemented a DatePicker with dateValue="{Birthday}" -- Birthday is the bound Object.

Another Property I configured is -editable="false"- because I just want to show the date.

Also I set displayFormat="dd.MM.yyyy".

Now I put everything into a grid to format the view. Code looks like this:

<l:Grid

    defaultSpan="L12 M12 S12"

    width="auto">

     <l:content>

          <f:SimpleForm

                 minWidth="1024"

                 maxContainerCols="2"

                 editable="false"

                 layout="ResponsiveGridLayout"

                 labelSpanL="3"

                 labelSpanM="3"

                 emptySpanL="4"

                 emptySpanM="4"

                 columnsL="2"

                 columnsM="2">

                 <f:content>

                      <Label text="{i18n>Birthday}">

                           <layoutData>

                                <l:GridData span="L2 M2 S2"/>

                           </layoutData>

                      </Label>

                      <DatePicker dateValue="{Birthday}" editable="false" displayFormat="dd.MM.yyyy">

                           <layoutData>

                                <l:GridData span="L10 M10 S10"/>

                           </layoutData>

                      </DatePicker>

                 </f:content>

            </f:SimpleForm>

     </l:content>

</l:Grid>

The problem now is that it looks like that:

Hopefully you can see that the date does not fit right into the grid-row. But the rest works perfectly.

How can I make it looking better?

Or can I use an other UI5-Element for the view of this date. (Without a formatter for example if you do it with a normal sap.m.Text)

Kind regards,

Jean-Luc Düe

TAMMEN IT SOLUTIONS

Tags:
replied

Hi Jean-Luc,

for displaying use a Text control and a data typr or formatter. In this JSBin see the second row with Label "Birthday 2" for an example.

If you use the DatePicker with editable ? "false" the label and the DatePicker are rendered at the top of the row and cause the DatePicker is higher than the label it does not look perfect.

So the trick is:

<Text text="{path: '/Birthday', type: 'sap.ui.model.type.Date'}">

         <layoutData>

              <l:GridData span="L5 M10 S7"/>

         </layoutData>

</Text>

JS Bin on jsbin.com

Another solution:

Another solution would be to set the editable property of the SimpleForm to true and set it to false for all your controls in the form.

That way you could easily switch between display and edit mode by binding the editable property of your controls to a model property and just switching the model property.

Regards Helmut

1 View this answer in context
Not what you were looking for? View more on this topic or Ask a question