Skip to Content

JSON TwoWay Binding Anomaly when in Table.

I'm experiencing an issue when binding a JSON model to a table that has input enabled and TwoWay binding. To illustrate better, check out the example on JSBIN Example and within the output screen, drag each slider and notice the different behaviour.. The top slider works as expected, but the others get stuck as you drag it. When looking at it in more detail, it's like the whole item in the table is getting refreshed each time anything in that row changes.

Anyone seen this and/or have any ideas how to stop this happening while keeping TwoWay binding on?

Thanks,

Matt

capture2.jpg (74.4 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Nov 02, 2017 at 10:05 PM

    Thanks to the community, there are a couple of ways of solving this. Easiest way (that works in my scenario) is to simply set "growing" to false and this goes away. (Thanks Al Templeton)

    The other alternative given to me by Boghyon Hoffmann is to provide a key property in the aggregation. (refer to #1736 (comment))

    Thanks all,

    Matt

    Add comment
    10|10000 characters needed characters exceeded

    • And if you read the doco - this explains it:

      setGrowing

      Sets a new value for property growing.

      If set to true, enables the growing feature of the control to load more items by requesting from the model. Note:: This feature only works when an items aggregation is bound. Growing must not be used together with two-way binding.

  • Nov 02, 2017 at 09:32 PM

    Hi Matt,

    I haven't put a slider in a table, but I have put one in a list, using a custom list item. The sliders work fine in this scenario:

    <List items="{path: 'Objectives>/Objectives', templateShareable: true}" >
         <CustomListItem>
            <Slider value="{Objectives>Weighting}" min="0" max="100" step="5"/>
         </CustomListItem>
    </List>
    Add comment
    10|10000 characters needed characters exceeded

  • Nov 02, 2017 at 11:52 AM

    Hi Matt

    Haven't seen this issue before - it might be a glitch in two-way binding to table rows since when you switch to one-way data binding, then the problem goes away...

    onInit: function(oEvent) {
      var oModel = new JSONModel({
        DiffWeighting: 25, 
        Objectives: [ 
          { Description: "Value 1", Weighting: 25}, 
          { Description: "Value", Weighting: 50}
        ]
      });
      oModel.setDefaultBindingMode(sap.ui.model.BindingMode.OneWay);
      this.getView().setModel(oModel, "Objectives");
    }

    Chris W

    Add comment
    10|10000 characters needed characters exceeded

    • Thanks Chris. OneWay binding does fix the behaviour somewhat, but then I have to put change events on all the fields plus other similar issues occur even with OneWay binding with more complex scenarios. e.g. The example is a simplified example I'm dealing but when you throw in OData based ComboBoxes lists, and more input fields; and it has other strange behaviour.

      Work around (if I have to go down that path), is I'll manage the aggregation programmatically, but I was just hoping I'd done something stupid and someone would tell me what the stupid thing was!

      BTW - This is happening from 1.44 to the latest UI5 release, but maybe I am the first one to do something like this! - It's a strange design pattern I'm going for based loosely on the following:

      https://sapui5.hana.ondemand.com/#/sample/sap.m.sample.TableEditable/preview

      Cheers,

      Matt