on ‎2016 Dec 23 6:38 AM
Hi All,
I'm trying to develop SAPUI5 application using smart table with the json model binding. While running the program I'm getting error I'm sharing that snapshot with you.I'm sharing my code, please suggest me to how to make this work.
And please say how to refer JSONModel data/entity set to the annotations.xml file
In view:
<smartTable:SmartTable
id="smartTable_ResponsiveTable"
smartFilterId="smartFilterBar"
tableType="ResponsiveTable"
editable="false"
entitySet="tableSet"
useVariantManagement="false"
useTablePersonalisation="false"
header="Products"
showRowCount="true"
useExportToExcel="false"
enableAutoBinding="true"
initiallyVisibleFields="name">
</smartTable:SmartTable>In Controller:
var array = [{
"name" : "Dinesh",
"id" : "123"
},
{
"name" : "Nikhil",
"id" : "456"
},{
"name" : "Pulkit",
"id" : "789"
}];
var model = new sap.ui.model.json.JSONModel();
model.setData({
tableSet: array
});
this.getView().byId("smartTable_ResponsiveTable").setModel(model);
});
I'm getting above error after running it. According to my knowledge smart table not able to get the data( that is entity set configuration issue). Please suggest me how to fix this and how to write annotations.xml file for JSONModel data
Regards,
Sai Ram Dinesh Pallapotu
Request clarification before answering.
Hi there. I used a Json Model with smart table. My JSON model is named "TableMlstJsonModel" inside of my controller. So you can see in the following how I used smart table with JSON model. You need to define custom list and custom columns:
<smartTable:SmartTable id="__smartTableMlst" entitySet="ProjectHeaderMstSet" tableBindingPath="TableMlstJsonModel>/ProjectHeaderMstSet"
header="{i18n>tableMlstTitle}" showRowCount="true" tableType="Responsive" showFullScreenButton="false" useVariantManagement="false"
enableAutoBinding="true" ignoredFields="ProjectDefinition,Method,Refnumber" useExportToExcel="false"
initiallyVisibleFields="MilestoneNumber,Description,OffsetMilestoneDate,OffsetMilestoneDateUnit">
<smartTable:customToolbar>
<m:OverflowToolbar design="Transparent">
<m:ToolbarSpacer/>
<m:Button type="Transparent" press="onRefreshMlstBtnPress" icon="sap-icon://refresh" tooltip="{i18n>refreshBtnTooltip}"/>
<m:Button type="Transparent" press="onAddMlstBtnPress" icon="sap-icon://add" tooltip="{i18n>createBtnTooltip}"
enabled="{objectView>/tableMlstBtnAddEnabledFinal}"/>
<m:Button type="Transparent" press="onDeleteMlstBtnPress" icon="sap-icon://delete" tooltip="{i18n>deleteBtnTooltip}"
enabled="{objectView>/tableMlstBtnDelEnabledFinal}"/>
</m:OverflowToolbar>
</smartTable:customToolbar>
<m:Table id="tableMlst" mode="MultiSelect" busy="{objectView>/tableMlstBusy}">
<m:columns>
<m:Column>
<m:customData>
<core:CustomData key="p13nData" value='\{"columnKey": "MilestoneNumber", "leadingProperty": "MilestoneNumber"}'/>
</m:customData>
<m:Text text="{/#ProjectHeaderMst/MilestoneNumber/@sap:label}"/>
</m:Column>
</m:columns>
<m:items>
<m:ColumnListItem type="Navigation" press="onPress">
<m:cells>
<m:Text text="{path: 'TableMlstJsonModel>MilestoneNumber', formatter: '.formatter.intNumber'}"/>
<m:Text text="{TableMlstJsonModel>Description}"/>
<m:Text text="{TableMlstJsonModel>OffsetMilestoneDate}"/>
<m:Text text="{TableMlstJsonModel>OffsetMilestoneDateUnit}"/>
<m:Text text="{TableMlstJsonModel>Activity}"/>
<m:Text text="{TableMlstJsonModel>ActivityName}"/>
<m:Text text="{TableMlstJsonModel>Aedat}"/>
<m:Text text="{TableMlstJsonModel>Aenam}"/>
<m:Text text="{TableMlstJsonModel>Erdat}"/>
<m:Text text="{TableMlstJsonModel>Ernam}"/>
<m:Text text="{TableMlstJsonModel>MlstSmlnr}"/>
<m:Text text="{TableMlstJsonModel>Network}"/>
<m:Text text="{TableMlstJsonModel>NetworkName}"/>
</m:cells>
</m:ColumnListItem>
</m:items>
</m:Table>
</smartTable:SmartTable>
<br>
But what you see here is not 100% related to the message that you see. The message is regarding the initiallyVisibleFields which is missing in you table definition. I just copied whole code because many people said it is not possible to use smart table with Json model or named models. All of these statements are wrong. You can use it but you need to provide custom list, as I did.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 12 | |
| 9 | |
| 7 | |
| 5 | |
| 4 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.