2016-12-19 3 views
0

데이터를 smartTable에 표시하고 있습니다. 이제 하나의 사용자 정의 아이콘 열을 추가하고 싶습니다. 이것이 가능한가 ? 예를 들어, 아래에 표시된 SmartTable 및 JSON 모델이 있고 첫 번째 열에 JSON Model 값을 텍스트로 표시하고 싶습니다.SmartTable에서 사용자 정의 열을 추가하는 방법은 무엇입니까?

<mvc:View 
    xmlns="sap.m" 
    xmlns:mvc="sap.ui.core.mvc" 
    controllerName="sap.ui.demo.smartControls.SmartTable" 
    xmlns:smartFilterBar="sap.ui.comp.smartfilterbar" 
    xmlns:smartTable="sap.ui.comp.smarttable"> 
    <smartFilterBar:SmartFilterBar 
    id="smartFilterBar" 
    entityType="Product"> 
    <smartFilterBar:controlConfiguration> 
    <smartFilterBar:ControlConfiguration 
    key="Category" visibleInAdvancedArea="true" 
    preventInitialDataFetchInValueHelpDialog="false"> 
    </smartFilterBar:ControlConfiguration> 
    </smartFilterBar:controlConfiguration> 
    </smartFilterBar:SmartFilterBar> 
    <smartTable:SmartTable 
    id="smartTable_ResponsiveTable" 
    smartFilterId="smartFilterBar" 
    tableType="ResponsiveTable" 
    editable="false" 
    entitySet="Products" 
    useVariantManagement="false" 
    useTablePersonalisation="false" 
    header="Products" 
    showRowCount="true" 
    useExportToExcel="false" 
    enableAutoBinding="true"> 
    </smartTable:SmartTable> 
    </mvc:View> 

컨트롤러의 onInit() 메소드에는 json 모델이 있습니다.

var oData = { "Text": "StackOverFlow"}; 
var oModel = sap.ui.model.json.JSONModel(oData); 
sap.ui.getCore().setModel(oModel); 

감사합니다, Mayank 여기 예제가있다

답변

0

:

SAP Developer Guide - Smart table

내가 하나로, OData 서비스와, JSON 데이터와 유사해야, 최근 응용 프로그램에서 이런 짓을 모델. 여기에 나의 모습입니다 :

\t <smartTable:SmartTable 
 
\t \t id="gSmartTable" 
 
\t \t initialise="onSmartTable" 
 
\t \t beforeRebindTable="onBeforeRebindTable" 
 
\t \t showOverlay="onShowOverlay" 
 
\t \t entitySet="Employees" 
 
\t \t smartFilterId="gSmartFilterBar" 
 
\t \t tableType="ResponsiveTable" 
 
\t \t useExportToExcel="false" 
 
\t \t useVariantManagement="false" 
 
\t \t useTablePersonalisation="true" 
 
\t \t persistencyKey="gSmartTable_Explored" 
 
\t \t header="Workers" 
 
\t \t showRowCount="true" 
 
\t \t enableAutoBinding="true" 
 
\t \t demandPopin="true"> \t 
 
\t \t 
 
\t \t 
 
\t \t 
 
\t <!-- Build table to handle custom field --> 
 
\t \t <Table id ="gEmployeesTable" growing="true" growingScrollToLoad="true" growingThreshold="20"> 
 
\t \t \t <columns> 
 
\t \t \t <Column width="100px" hAlign="Left"> 
 
\t \t \t \t \t <customData> 
 
\t \t \t \t \t \t <!-- Custom Field --> 
 
\t \t \t \t \t \t <core:CustomData key="p13nData" 
 
\t \t \t \t \t \t \t value='\{"columnKey": "Pernr", "maxLength": "5","columnIndex":"0", "leadingProperty": "Pernr"}' /> 
 
\t \t \t \t \t </customData> 
 
\t \t \t \t \t \t <Text text="{i18n>tableColumnEmployeeID}" /> 
 
\t \t \t \t </Column> 
 
\t \t \t \t <Column width="100px" hAlign="Left"> 
 
\t \t \t \t \t <customData> 
 
\t \t \t \t \t \t <!-- Custom Field --> 
 
\t \t \t \t \t \t <core:CustomData key="p13nData" 
 
\t \t \t \t \t \t \t value='\{"columnKey": "ZQ_STAT", "maxLength": "5","columnIndex":"4", "leadingProperty": "ZQ_STAT"}' /> 
 
\t \t \t \t \t </customData> 
 
\t \t \t \t \t \t <Text text="{i18n>tableColumnStatus}" /> 
 
\t \t \t \t </Column> 
 
\t \t \t </columns> 
 
\t \t \t <items> 
 
\t \t \t \t <!-- Table Navigation --> 
 
\t \t \t \t <ColumnListItem type="Navigation" press="onPress"> 
 
\t \t \t \t \t <cells> 
 
\t \t \t \t \t \t <!-- Use formatter to dispay Pernr --> 
 
\t \t \t \t \t <Text text="{ 
 
\t \t \t \t \t path: 'Pernr', 
 
\t \t \t \t \t formatter: '.formatter.stripZeros' 
 
\t \t \t \t \t }" /> 
 
\t \t \t \t \t </cells> 
 
\t \t \t \t \t <cells> 
 
\t \t \t \t \t \t <!-- Use formatter to dispay icon colour based on status field value (0,1,2,3) --> 
 
\t \t \t \t \t \t <core:Icon 
 
\t \t \t \t \t \t src="{ 
 
\t \t \t \t \t \t \t path: 'ZQ_STAT', 
 
\t \t \t \t \t \t \t formatter: '.formatter.iconVis' 
 
\t \t \t \t \t \t \t }" 
 
\t \t \t \t \t \t color="{ 
 
\t \t \t \t \t \t \t path: 'ZQ_STAT', 
 
\t \t \t \t \t \t \t formatter: '.formatter.iconColour' 
 
\t \t \t \t \t \t \t }"/> 
 
\t \t \t \t \t </cells> 
 
\t \t \t \t </ColumnListItem> 
 
\t \t \t </items> 
 
\t \t </Table> 
 
\t <!-- End Custom Table --> 
 
\t 
 
\t <!-- End Smart Table --> 
 
\t </smartTable:SmartTable>

내가 데이터에 대한 포맷터와, 두 개의 사용자 정의 필드를 추가 할 수 있었다. 사용자 정의 열을 먼저 표시하려면 'columnIndex'속성을 적절하게 설정하십시오.

희망 하시겠습니까?

관련 문제