The "customData" class doesn't exist in the "sap.ui.core" namespace

1k Views Asked by At

tried following this guide: https://blogs.sap.com/2016/05/17/coloring-table-rows-conditionally-in-sap-ui5-xml-views-based-on-odata-service/ but its impossible for me to add customData to my treetable. Any helpers? https://sapui5.hana.ondemand.com/sdk/#/api/sap.ui.core.CustomData pretty sure this exists idk

                            <k:TreeTable
                                id="treeTable"
                                selectionMode="Single"
                                enableColumnReordering="false"
                                visibleRowCountMode="Auto"
                                rows="{
                                    path : '',
                                    filters: '',
                                    parameters : {
                                        treeAnnotationProperties : {
                                            hierarchyLevelFor : 'HierarchyLevel',
                                            hierarchyNodeFor : 'NodeId',
                                            hierarchyParentNodeFor : 'ParentNodeID',
                                            hierarchyDrillStateFor : 'DrillState'
                                        }
                                    }
                                }">
                                <k:columns>
                                    <k:Column label="">
                                        <k:template>
                                            <Text text="{Description}" wrapping="false" />
                                        </k:template>
                                    <core:customData>
                                                <core:CustomData key="mydata" value="{HierarchyLevel}" writeToDom="true"></core:CustomData>
                                    </core:customData>
                                    </k:Column>
                                </k:columns>
                            </k:TreeTable>
2

There are 2 best solutions below

1
ChristopheN On

usually what I do is that I insert a xmlns tag at the header <mvc:View> like this : <mvc:View xmlns:customData="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1">.

And then

<Column>
 <Text text="{i18n>SomeText}"/>
 <customData>
  <core:CustomData key="SomeKey" value="SomeValue"/>
 </customData>
</Column>

Anyway check your xmlns definition at the top of the XML view.

0
michel luther On

I think your issue is that your aggregation should be written like this:

<k:TreeTable
                                id="treeTable"
                                selectionMode="Single"
                                enableColumnReordering="false"
                                visibleRowCountMode="Auto"
                                rows="{
                                    path : '',
                                    filters: '',
                                    parameters : {
                                        treeAnnotationProperties : {
                                            hierarchyLevelFor : 'HierarchyLevel',
                                            hierarchyNodeFor : 'NodeId',
                                            hierarchyParentNodeFor : 'ParentNodeID',
                                            hierarchyDrillStateFor : 'DrillState'
                                        }
                                    }
                                }">
                                <k:columns>
                                    <k:Column label="">
                                        <k:template>
                                            <Text text="{Description}" wrapping="false" />
                                        </k:template>
                                    <k:customData>
                                                <core:CustomData key="mydata" value="{HierarchyLevel}" writeToDom="true"></core:CustomData>
                                    </k:customData>
                                    </k:Column>
                                </k:columns>
                            </k:TreeTable>

Because your aggregation identifier customData belongs to the Column control which is part of the k-namespace. Only the CustomData-Element is from the sap.ui.core namespace.