Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/372.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在对象页面布局的块视图中将oData模型绑定到表?_Javascript_Xml_Odata_Sapui5_Sap Fiori - Fatal编程技术网

Javascript 如何在对象页面布局的块视图中将oData模型绑定到表?

Javascript 如何在对象页面布局的块视图中将oData模型绑定到表?,javascript,xml,odata,sapui5,sap-fiori,Javascript,Xml,Odata,Sapui5,Sap Fiori,如何将oData entityset响应中的模型数据绑定到xml块视图中的表? 我希望“直接”将模型数据设置/绑定到视图中的表行,而不是通过事件将其绑定到对象页视图控制器方法中的表行 Below code from block view: <Table id="sponClassTable" growing="true" growingThreshold="5" inset="false" items="{ path: '/SponClassSet'

如何将oData entityset响应中的模型数据绑定到xml块视图中的表? 我希望“直接”将模型数据设置/绑定到视图中的表行,而不是通过事件将其绑定到对象页视图控制器方法中的表行

   Below code from block view:

    <Table id="sponClassTable" growing="true" growingThreshold="5"
inset="false"
    items="{
        path: '/SponClassSet'
    }">

   Binding to table cells in block view:

            <items>
        <ColumnListItem>
            <cells>
                <Text 
                    text="{sponsModel>SponsoredClass}"/>
                <Text
                    text="{sponsModel>ClassType}" />
                <Text
                    text="{sponsModel>IdcRelevant}" />
                <Text
                    text="{sponsModel>SponsClassDesc}" />
                <Text
                    text="{sponsModel>SpClFromDt}" />       
                <Text
                    text="{sponsModel>SpClDefault}" />                      

            </cells>
        </ColumnListItem>
    </items>
</Table>
下面是块视图中的代码:
绑定到块视图中的表格单元格:

您正在将表绑定到不同的型号

表项绑定到未命名的模型路径:'/SponClassSet',文本单元格绑定到名为sponsModel Text=“{sponsModel>SponsoredClass}的命名模型? odata模型使用的名称是什么?unnamed还是sponsModel?在代码中搜索方法setModel,或者查看manifest.json中为odata模型选择的名称。 除此之外,还可以查看OpenUi5文档中视图是如何绑定到数据模型的

<Table id="sponClassTable" growing="true" growingThreshold="5"
inset="false"
    items="{
        path: '/SponClassSet'
    }">

   Same sub-view, here Binding to table rows:
            <items>
        <ColumnListItem>
            <cells>
                <Text 
                    text="{sponsModel>SponsoredClass}"/>
                <Text
                    text="{sponsModel>ClassType}" />
                <Text
                    text="{sponsModel>IdcRelevant}" />
                <Text
                    text="{sponsModel>SponsClassDesc}" />
                <Text
                    text="{sponsModel>SpClFromDt}" />       
                <Text
                    text="{sponsModel>SpClDefault}" />                      

            </cells>
        </ColumnListItem>
    </items>
</Table>

相同的子视图,此处绑定到表行:

您正在将表绑定到不同的型号

表项绑定到未命名的模型路径:'/SponClassSet',文本单元格绑定到名为sponsModel Text=“{sponsModel>SponsoredClass}的命名模型? 您的odata型号使用什么名称?还是海绵模型?在代码中搜索方法setModel,或者查看manifest.json,您为Odata模型选择了哪个名称。 除此之外,还可以查看OpenUi5文档中视图是如何绑定到数据模型的

<Table id="sponClassTable" growing="true" growingThreshold="5"
inset="false"
    items="{
        path: '/SponClassSet'
    }">

   Same sub-view, here Binding to table rows:
            <items>
        <ColumnListItem>
            <cells>
                <Text 
                    text="{sponsModel>SponsoredClass}"/>
                <Text
                    text="{sponsModel>ClassType}" />
                <Text
                    text="{sponsModel>IdcRelevant}" />
                <Text
                    text="{sponsModel>SponsClassDesc}" />
                <Text
                    text="{sponsModel>SpClFromDt}" />       
                <Text
                    text="{sponsModel>SpClDefault}" />                      

            </cells>
        </ColumnListItem>
    </items>
</Table>

相同的子视图,此处绑定到表行:

你好,弗朗西索,谢谢你的提示!我给entityset记录提供了错误的路径,这些记录来自items路径中的命名模型。我在表标记中为items属性指定了'entityset'的路径,而不是命名模型的路径。现在我在xml块视图中的表标记中将路径更改为:items=“{path:'sponsModel>/results'}”,并且我能够在表中成功填充数据/记录。谢谢您的提示!我给entityset记录提供了错误的路径,这些记录来自items路径中的命名模型。我在表标记中为items属性指定了“entityset”的路径,而不是命名模型的路径。现在,我在xml块视图中的表标记中将路径更改为:items=“{path:'sponsModel>/results'}”,并且我能够成功填充表中的数据/记录