2016-02-12 22 views
1

當試圖連接的自定義數據屬性來使用XML視圖的表列中,我收到在Chrome瀏覽器控制檯以下錯誤:SAP openui5:錯誤安裝的CustomData時的表列模板

2016-02-12 12:02:38.331040 CustomData with key strikethrough should be written to HTML of Element sap.m.Text#__text10-col1-row6 but the value is not a string. - 

我列定義如下:

<table:Column width="200px"> 
    <Label text="Plant Variation"/> 
    <table:template> 
     <Text text="{__textpvvalue__}"> 
      <customData> 
       <core:CustomData key="strikethrough" value="{__rowstyle__}" writeToDom="true" /> 
      </customData> 
     </Text> 
    </table:template> 
</table:Column> 

屬性實際上是正確寫出到DOM,但它好像因爲我確實傳遞一個字符串值「價值」不應該出現的錯誤信息自定義數據對象的屬性。我也嘗試將自定義數據對象的「value」屬性硬編碼爲「test」,認爲它可能是數據綁定相關的問題,但得到了相同的結果。

由於數據屬性實際上被正確地寫入到DOM中,這比堵塞問題更令人煩惱。我想知道這是否是我在XML視圖中沒有正確使用自定義數據的結果,因爲我對openui5很新穎。

謝謝, 馬特

+0

你能在這裏(https://github.com/SAP/openui5/blob/master/src/sap.ui.core/src/sap/ui/core/CustomData.js#L82添加一個斷點)並查看實際導致問題的原因?要查看所有源文件,請在URL路徑末尾添加'?sap-ui-debug = true'。 – Marc

+0

@Matt Hopkins:關於SAPUI5表格控件問題的問題(無法讀取未定義的屬性'attr')消失。這是否意味着這個問題得到解決?如果是,那麼它是如何解決的? – valeryan

回答

0

使用綁定格式。格式null某些行的值爲空字符串

var customData = new sap.ui.core.CustomData({ 
    key: 'strikethrough', 
    writeToDom: true 
}); 
customData.bindProperty('value', { 
    path: '__rowstyle__', 
    formatter: function (value) { 
     if (!value) { 
      value = ''; 
     } 
     return value; 
    } 
}); 

或查看格式化程序。請參閱Step 23: Custom Formatters

sap.ui.define([], function() { 
    return { 
     customDataFormatter: function (value) { 
      if (!value) { 
       value = ''; 
      } 
      return value; 
     } 
    }; 
});