2016-12-26 3 views
0

테이블에 강조 표시 행 기능을 추가하려고합니다. 그 값은 백엔드 odata 서비스에서 가져 오는 값입니다. 나는이 말하는거야 : 나는 위의 링크에서 언급 한 바와 같이 xmlviewSAPUI5 : 표 행 강조 표시를위한 대체 색상

<mvc:View xmlns:mvc="sap.ui.core.mvc" controllerName="generated.app.controller.14768629992738663_S0" xmlns:m="sap.m" xmlns:html="http://www.w3.org/1999/xhtml"> 
<m:Page id="sap_Responsive_Page_0" showHeader="true" title="Manage Tenants" showFooter="true" showNavButton="true"> 
    <m:content> 
     <m:SearchField id="sap_Responsive_Page_0-content-sap_m_SearchField-1476864205399" placeholder="Search" showSearchButton="true" 
      visible="true" width="268.140625px" liveChange="onFilter"/> 
     <m:Toolbar id="sap_Responsive_Page_0-content-sap_m_Toolbar3-1476863171475" width="auto" design="Transparent" height="46px" visible="true" 
      enabled="true"> 
      <m:content> 
       <m:Text id="sap_Responsive_Page_0-content-sap_m_Toolbar3-1476863171475-content-sap_m_Text-1" text="Items" width="auto" maxLines="1" 
        wrapping="false" textAlign="Begin" textDirection="Inherit"/> 
       <m:ToolbarSpacer id="sap_Responsive_Page_0-content-sap_m_Toolbar3-1476863171475-content-sap_m_ToolbarSpacer-2" width=""/> 
       <m:Button id="sap_Responsive_Page_0-content-sap_m_Toolbar3-1476863171475-content-sap_m_Button-1476863865529" iconDensityAware="false" 
        text="" type="Default" icon="sap-icon://add" iconFirst="true" width="auto" enabled="true" visible="true" press="_onButtonPress2"/> 

       <m:Button id="sap_Responsive_Page_0-content-sap_m_Toolbar3-1476863171475-content-sap_m_Button-4" iconDensityAware="false" text="" 
        type="Transparent" icon="sap-icon://drop-down-list" iconFirst="true" width="auto" enabled="true" visible="true" press="onGroup"/> 
      </m:content> 
      <m:tooltip/> 
     </m:Toolbar> 
     <m:Table id="sap_Responsive_Page_0-content-build_simple_Table-1476863214613" width="100%" noDataText="No data" selectionMode="MultiToggle" 
     growing="false" growingThreshold="20" growingScrollToLoad="false" items="{path:'/BYD'}" itemPress="_onTableItemPress" ariaLabelledBy="title"> 

      <m:headerToolbar/> 
      <m:columns> 
       <m:Column id="sap_Responsive_Page_0-content-build_simple_Table-1476863214613-columns-build_simple_Column-1" width="auto" hAlign="Left" 
        vAlign="Top" minScreenWidth="Tablet" demandPopin="true" popinDisplay="Inline" mergeDuplicates="false"> 
        <m:header> 
         <m:Text id="sap_Responsive_Page_0-content-build_simple_Table-1476863214613-columns-build_simple_Column-1-header-sap_m_Text-1" text="Tenant" 
          width="auto" maxLines="1" wrapping="false" textAlign="Begin" textDirection="Inherit"/> 
        </m:header> 
        <m:footer/> 
       </m:Column> 
       <m:Column id="sap_Responsive_Page_0-content-build_simple_Table-1476863214613-columns-build_simple_Column-2" width="auto" hAlign="Left" 
        vAlign="Top" minScreenWidth="Tablet" demandPopin="true" popinDisplay="Block" mergeDuplicates="false"> 
        <m:header> 
         <m:Text id="sap_Responsive_Page_0-content-build_simple_Table-1476863214613-columns-build_simple_Column-2-header-sap_m_Text-1" 
          text="Division" width="auto" maxLines="1" wrapping="false" textAlign="Begin" textDirection="Inherit"/> 
        </m:header> 
        <m:footer/> 
       </m:Column> 
       <m:Column id="sap_Responsive_Page_0-content-build_simple_Table-1476863214613-columns-build_simple_Column-3" width="auto" hAlign="Left" 
        vAlign="Top" minScreenWidth="Tablet" demandPopin="true" popinDisplay="Block" mergeDuplicates="false"> 
        <m:header> 
         <m:Text id="sap_Responsive_Page_0-content-build_simple_Table-1476863214613-columns-build_simple_Column-3-header-sap_m_Text-1" text="Type" 
          width="auto" maxLines="1" wrapping="false" textAlign="Begin" textDirection="Inherit"/> 
        </m:header> 
        <m:footer/> 
       </m:Column> 
       <m:Column id="sap_Responsive_Page_0-content-build_simple_Table-1476863214613-columns-build_simple_Column-1476863521840" width="auto" 
        hAlign="Left" vAlign="Top" minScreenWidth="Tablet" demandPopin="true" popinDisplay="Inline" mergeDuplicates="false"> 
        <m:header> 
         <m:Text id="sap_Responsive_Page_0-content-build_simple_Table-1476863214613-columns-build_simple_Column-1476863521840-header-sap_m_Text-1" 
          text="Status" width="auto" maxLines="1" wrapping="false" textAlign="Begin" textDirection="Inherit"/> 
        </m:header> 
        <m:footer/> 
       </m:Column> 
      </m:columns> 
      <m:items> 
       <m:ColumnListItem id="sap_Responsive_Page_0-content-build_simple_Table-1476863214613-items-build_simple_Row-1" type="Navigation" press="onPress"> 
        <m:cells> 
         <m:ObjectIdentifier 
          id="sap_Responsive_Page_0-content-build_simple_Table-1476863214613-items-build_simple_Row-1-cells-sap_m_ObjectIdentifier-1" title="{TENANTNAME}" 
          text="{ID}" titleActive="false" visible="true"/> 
         <m:Text id="sap_Responsive_Page_0-content-build_simple_Table-1476863214613-items-build_simple_Row-1-cells-sap_m_Text-2" text="{DIVISION}" 
          width="auto" maxLines="1" wrapping="false" textAlign="Begin" textDirection="Inherit"/> 
         <m:Text 
          id="sap_Responsive_Page_0-content-build_simple_Table-1476863214613-items-build_simple_Row-1-cells-build_simple_TableCell-1476863445271-content-sap_m_Text-1476863453798" 
          text="{TYPES}" width="auto" maxLines="1" wrapping="false" textAlign="Begin" textDirection="Inherit"/> 
         <m:ObjectStatus 
          id="sap_Responsive_Page_0-content-build_simple_Table-1476863214613-items-build_simple_Row-1-cells-build_simple_TableCell-1476863521843-content-sap_m_ObjectStatus-1476863547560" 
          title="" text="{STATUS}" state="{STATUSFLAG}"/> 
        </m:cells> 
       </m:ColumnListItem> 
      </m:items> 
     </m:Table> 
    </m:content> 
    <m:footer> 
     <m:Bar id="sap_Responsive_Page_0-footer-sap_m_Bar-1" design="Auto"> 

     </m:Bar> 
    </m:footer> 
    <m:headerContent/> 
    <m:subHeader/> 
    <m:customHeader/> 
</m:Page> 

을 사용하고있는 뷰 enter link description here

을, 나는의 ID를 언급하고있는 CSS 파일을 생성 표를 사용하여 강조 표시 기능을 추가하십시오.

#sap_Responsive_Page_0-content-build_simple_Table-1476863214613 tbody tr:nth-child(even) { 
background: rgb(24, 245, 25); 

}

나는 manifest.json을

"sap.ui5": { 


"resources": { 
     "css": [{ 
      "uri": "css/style.css" 
     }] 
    } 

}

자원의 CSS를 추가 한하지만이 일 것으로 예상된다로서이 일을하지 않았다.

여기에서해야 할 것이 더 많거나 다른가요?

+0

가능 중복 [SAPUI5 : 테이블의 행 또는 열을 강조 표시 다른 색상 (https://stackoverflow.com/questions/27308502/sapui5 -alternate-color-highlight-table-rows-columns) – boghyon

답변

0

id는 SAPUI5에서 CSS에 사용하지 말아야합니다. 런타임에 ID가 생성되고 시간이 지남에 따라 일관성이 유지된다는 보장이 없습니다 (+ XML에서 지정한 ID는 DOM의 실제 ID가 아닙니다. 요소).

CSS 선택기를 변경하여 내장 CSS 클래스 (SAPUI5가 시간이 지남에 따라 지원함)를 사용하거나 자신 만의 클래스를 추가하십시오.

.XML

<Table class="myHighlightClass" .... 

.CSS

.myHighlightClass { ... 
+0

네, 제 자신의 클래스를 추가하고 CSS로 호출하면 작동합니다 !! 그 점에 대해 감사드립니다. 하지만 SAP에서 왜 ID를 사용하는 것이 좋을지 궁금합니다 ... – dexter

+0

샘플이 정확하게 동일한 스타일을 사용하는 '스타일 추가 클래스'를 참조합니다. 신분증] –