cancel
Showing results for 
Search instead for 
Did you mean: 

Issue with binding

former_member541649
Active Participant
0 Kudos

Hi,

I am facing some issue with UI binding on my view.

I have an sap.m.Table control in my xml view which I am trying to populate with some sample data in the onInit method of the controller.

But the table is rendered empty.. Could you please suggest what I am missing!!

This is my onInit method:

onInit: function(){
var mappingCollection = [];
var singleMapping = { "targetField": "Sample Target Field", "sourceField": "Some Source Field"}
mappingCollection.push(singleMapping);
var oMappingModel = new JSON();
oMappingModel.setProperty("/mapping",mappingCollection);
sap.ui.getCore().setModel(oMappingModel, "mappingModel");

},

This is my XML view Table control:

<Panel class="sapUiResponsiveMargin" width="auto">

  <Table id="mappingTable"

    items="{mappingModel>/mapping}">

  <headerToolbar>

  <Toolbar>

  <Label text="Mapping"/>

  </Toolbar>

  </headerToolbar>

  <columns>

  <Column width="12em">

  <Text text="Target Field" />

  </Column>

  <Column width="12em">

  <Text text="Source Field" />

  </Column>

  </columns>

  <items>

  <ColumnListItem>

  <cells>

  <Text text="{mappingModel>targetField}" valueLiveUpdate="true"></Text>

  <Text value="{mappingModel>sourceField}" valueLiveUpdate="true"></Text>

  </cells>

  </ColumnListItem>

  </items>

  </Table>

</Panel>

Accepted Solutions (0)

Answers (2)

Answers (2)

saivellanki
Active Contributor
0 Kudos

Hi Parul,

Include data-sap-ui-xx-bindingSyntax="complex" in SAPUI5 bootstrap.

And also Text doesn't have a value property, you have to use Input control for the same.

I used your code, check the working sample - JS Bin - Collaborative JavaScript Debugging

Regards,

Sai Vellanki.

former_member541649
Active Participant
0 Kudos

Thanks a lot Sai, I realized I had text in the column where it should have been Input... but what else did you change to make it work??

saivellanki
Active Contributor
0 Kudos

Parul,

I think in your bootstrap data-sap-ui-xx-bindingSyntax="complex" is not included.

Check your bootstrap, it should be -


<script id="sap-ui-bootstrap"

        type="text/javascript"

        src="/resources/sap-ui-core.js"

        data-sap-ui-theme="sap_bluecrystal"

        data-sap-ui-libs="sap.m"

        data-sap-ui-xx-bindingSyntax="complex">

Regards,

Sai Vellanki.

former_member541649
Active Participant
0 Kudos

Hi Sai,

I do have data-sap-ui-bindingSyntax = "complex" in my bootstrap, but without the xx.

I made this work by setting the model on the view controller itself instead of the core and moving the table and other stuff I had on a single view, but I am not quite sure why it didn't work for me earlier.

I guess I will start from a clean slate again tomorrow.

Thanks,

Parul

kedarT
Active Contributor
0 Kudos

Hi Parul,

Do you see the data in the model in debugging mode?

Why not do something like this - SAPUI5 SDK - Demo Kit

former_member541649
Active Participant
0 Kudos

Hi Kedar,

yes, I do see the data in model, just not in the table...