SAPUI5 Smart Table : How to Inject my own column into smart Table, Default columns, Define formatters, and Define aggregated columns

独自空忆成欢 提交于 2019-12-20 05:44:37

问题


I am Using Smart Table. i want to know the following regarding this,

  1. How Make some columns visible by default
  2. How can we inject our own columns into smart table, like if we want to display the icon based on the gender(male or female).
  3. How can we set aggregated columns like Name (FirstName + LastName).
  4. How to define the sorting and filtering on Aggregated Columns.

回答1:


XML View

<core:View xmlns:core="sap.ui.core" xmlns="sap.m" xmlns:smartFilterBar="sap.ui.comp.smartfilterbar" xmlns:smartTable="sap.ui.comp.smarttable" controllerName="smartTable.controller" class="sapUiSizeCompact">          
        <Page id="page" title="Customer Line Items">            
            <smartTable:SmartTable entitySet="Patient" tableType="ResponsiveTable" useExportToExcel="true" useVariantManagement="true" useTablePersonalisation="true" header="Line Items" showRowCount="true" persistencyKey="SmartTableAnalytical1" enableAutoBinding="true">
                <Table>
                    <columns>
                        <Column>
                            <customData> 
                                <core:CustomData key="p13nData" value='\{"columnKey": "PatientId","leadingProperty": ["LastName", "FirstName"],"sortProperty": "LastName","filterProperty": "LastName"}'/>
                            </customData>
                            <Label text="Concatenated Name" />

                        </Column>
                        <Column>
                            <customData> 
                                <core:CustomData key="p13nData" value='\{"columnKey": "Status","leadingProperty": "Status","sortProperty": "Status","filterProperty": "Status"}'/>
                            </customData>
                            <Label text="Status" />

                        </Column>
                    </columns>
                    <items>
                        <ColumnListItem>
                        <cells>
                            <ObjectIdentifier title="{LastName} {FirstName}"/>
                            <Text text="{Status}"/>
                        </cells>
                    </ColumnListItem>
                </items>
                </Table>
            </smartTable:SmartTable>
        </Page>
    </core:View>

Controller In Controller you have to set the odata model to the view or smartTable.




回答2:


To build columns automatically from Service use smart table.
1.How Make some columns visible by default?
To get initial column you need specific annotation called LineItem. The fields under this will automatically built by smart.
How can we inject our own columns into smart table, like if we want to display the icon based on the gender(male or female).
How can we set aggregated columns like Name (FirstName + LastName).
How to define the sorting and filtering on Aggregated Columns.

Answers to all of this would be build your sap.m.Table and wrap it inside the smart table. By using this the columns built by you will you have custom coded functionality and column built by smart table (for other fields in service)



来源:https://stackoverflow.com/questions/32114675/sapui5-smart-table-how-to-inject-my-own-column-into-smart-table-default-colum

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!