2017-06-22 82 views
1

當我試圖篩選的東西(智能過濾),我得到一個404錯誤,檢查我的有效載荷我看到有在它沒有實體:如何設置智能過濾EntitySet的

GET null/$count?$filter=startswith(undefined,22) HTTP/1.1 

這一項工作

GET RfcSearchRequisitionsSet?$skip=0&$top=100&$filter=(Banfn%20eq%20%2722%27)&$select=Bsart%2cBanfn%2cBnfpo%2cWerks HTTP/1.1 

XML

   <smartFilterBar:SmartFilterBar id="smartFilterBar" 
        entityType="RfcSearchRequisitions"> 
        <smartFilterBar:controlConfiguration> 
         <smartFilterBar:ControlConfiguration 
          key="Banfn" index="1" groupId="_BASIC" width="300px" 
          visibleInAdvancedArea="true"> 

         </smartFilterBar:ControlConfiguration> 
        </smartFilterBar:controlConfiguration> 
       </smartFilterBar:SmartFilterBar> 
       <smartTable:SmartTable id="smartTable" 
        entitySet="RfcSearchRequisitionsSet" smartFilterId="smartFilterBar"...> 

批註

<Annotation Term="com.sap.vocabularies.UI.v1.LineItem"> 
<Collection> 
<Record Type="com.sap.vocabularies.UI.v1.DataFieldForAnnotation"> 
<PropertyValue Property="Label" String="DocType"/> 
<PropertyValue Property="Target" AnnotationPath="BSART"/> 
</Record> 
+1

也許你至少提供編碼,在那裏你創建這個智能過濾? –

+0

當然,我已經分享了xml –

+0

您使用哪種類型的odatamodel?有沒有正確的元數據?這個odatamodel是否被設置爲您的視圖的默認模型? –

回答

-1

的問題是與註釋,它們應該是這樣:

<Record Type="com.sap.vocabularies.UI.v1.DataField"> 
    <PropertyValue Property="Label" String="DateCreated"/> 
    <PropertyValue Property="Value" Path="Erdat"/> 
</Record> 
1

請在您的控制器中複製下面的代碼片段,並將該方法添加到SmartTable XML中的事件「beforeRebindTable」中。像:beforeRebindTable =「handleBeforeRebindTable」

handleBeforeRebindTable: function(oEvent) { 
     var mBindingParams = oEvent.getParameter("bindingParams"), 
      aCustomFilters = [], 
      sFilterValue = 22; // it's an example, use your filter value 

     // Getting filter parameters value 
     if (sFilterValue) { 
      aCustomFilters.push(new sap.ui.model.Filter("Banfn", sap.ui.model.FilterOperator.StartsWith, sFilterValue)); 
     } 

      var oOwnMultiFilter = new sap.ui.model.Filter(aCustomFilters, true); 
      if (mBindingParams.filters[0] && mBindingParams.filters[0].aFilters) { 
       var oSmartTableMultiFilter = mBindingParams.filters[0]; 
       // if an internal multi-filter exists of your smart table then combine custom multi-filters and internal multi-filters with an AND 
       mBindingParams.filters[0] = new sap.ui.model.Filter([oSmartTableMultiFilter, oOwnMultiFilter], true); 
      } else { 
       mBindingParams.filters.push(oOwnMultiFilter); 
      } 

    }, 
+0

做到這一點,沒有什麼變化 –

+0

我認爲你可以停止使用這個片段計數呼叫,因爲計數是由智能表本身處理的。在你的component.js的init方法中使用代碼。 ** this.getModel().setDefaultCountMode(CountMode.Inline); ** –

+0

也定義**「sap/ui/model/odata/CountMode」**上面的component.js –