cancel
Showing results for 
Search instead for 
Did you mean: 

Table Select Dialog - oData (Model) response values not shown

ct-ch
Explorer
0 Kudos

Hi there

A question. I've created a Table Select Dialog in a fragment, but the oData values as service response are not shown. Here my coding:

		onCheckAvailability: function (oEvent) {
var oInputModel = this.getModel("inputModel");
var sMatnr = oInputModel.getProperty("/Material");
var sWerks = oInputModel.getProperty("/Plant");
var sLgort = oInputModel.getProperty("/StorageLocation");
var aFilters = [];
aFilters.push(new Filter("Material", sap.ui.model.FilterOperator.EQ, sMatnr));
aFilters.push(new Filter("Plant", sap.ui.model.FilterOperator.EQ, sWerks));
aFilters.push(new Filter("Lgort", sap.ui.model.FilterOperator.EQ, sLgort));
var fnSuccess = function (oData, oResponse) {
var oModel = this.getView().getModel("materialModel");
oModel.setData(oData.results);
oModel.refresh();
this._oDialog.getBinding("items").refresh();
}.bind(this);
var fnError = function (oError) {
var oMessage = JSON.parse(oError.responseText);
var sMessage = oMessage.error.message.value;
MessageBox.confirm(sMessage, {
icon: MessageBox.Icon.WARNING,
title: "Fehler!",
actions: [MessageBox.Action.OK],
onClose: function (sAction) {}.bind(this)
});
}.bind(this);
var oDataModel = this.getView().getModel();
oDataModel.read("/MaterialAvailablitySet", {
success: fnSuccess,
error: fnError,
filters: aFilters
});
if (!this._oDialog) {
this.idPrefix = this.createId("TableDialog");
this._oDialog = sap.ui.xmlfragment(
this.idPrefix,
this.sMaterialAvailableFragmentName,
this
);
var bDraggable = oEvent.getSource().data("draggable");
this._oDialog.setDraggable(bDraggable === "true");
var bResizable = oEvent.getSource().data("resizable");
this._oDialog.setResizable(bResizable === "false");
this.getView().addDependent(this._oDialog);
jQuery.sap.syncStyleClass("sapUiSizeCompact", this.getView(), this._oDialog);
var oDialogModel = new JSONModel();
this.getView().setModel(oDialogModel, "materialModel");
}
this._oDialog.open();
},

I see there is a response with values from the backend, but the visibility inside the table select dialog is not possible. Here my fragment definition:

<core:FragmentDefinition xmlns="sap.m" xmlns:core="sap.ui.core">
<TableSelectDialog noDataText="{i18n>noMaterialFound}" title="{i18n>materialAvailability}" confirm="handleClose" cancel="handleClose"
items="{ path : '/MaterialAvailablitySet', sorter : { path : 'Material', descending : false } }">
<ColumnListItem>
<cells>
<Text text="{Qty}"/>
<Text text="{Lgort}"/>
<Text text="{LgortDescr}"/>
</cells>
</ColumnListItem>
<columns>
<Column width="12em">
<header>
<Text text="{i18n>materialQty}"/>
</header>
</Column>
<Column minScreenWidth="Tablet" demandPopin="true">
<header>
<Text text="{i18n>lgortName}"/>
</header>
</Column>
<Column minScreenWidth="Desktop" demandPopin="true" hAlign="End">
<header>
<Text text="{i18n>lgortDescr}"/>
</header>
</Column>
</columns>
</TableSelectDialog>
</core:FragmentDefinition>

Thanks for urgent help.

Cheers

Cengiz

Accepted Solutions (0)

Answers (4)

Answers (4)

junwu
Active Contributor
0 Kudos

1. you don't know how to use model correctly(jsonmodel vs odatamodel)

from your code, i don't see there is a need to put the data into jsonmodel and then consume it

2. you don't know how binding works

if your model has name, your binding should also mention that name if you try to bind to that model.

ct-ch
Explorer
0 Kudos

Thanks. Worked for me. But I do not understand what was the problem working with properties in my view.

Cheers

Cengiz

ct-ch
Explorer
0 Kudos

Thanks. Unfortunately, that occurs a warning like "List Binding is not bound against a list for /" and "The Data Services request was not understood due to a malformed syntax"

junwu
Active Contributor

your code is quite messy...

try this. add model name to other binding

items="{ path : 'materialModel>/',
<Text text="{materialModel>Qty}"/>
<Text text="{materialModel>Lgort}"/>
<Text text="{materialModel>LgortDescr}"/>
junwu
Active Contributor
0 Kudos
items="{ path : '/',

check if it helps