cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove/change a binding correctly?

05-27-2014 10:41 AM
6642 views 8 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Hey,

I'm trying to remove an aggregation binding of a table, because I want to set another one on it.

I need something like this:

if ( mytable.isBound())

mytable.unbindRows()

mytable.bindRows()

... but istBound() returns always "false", although it is bound and data are shown. The new binding is working well, but I think the old Binding remains at the model -> which causes (old) requests on a refresh.

What is generally the correct way to call ".bindRows()" many times, without getting too many old requests?

Or how can I remove a Binding totally from my model?

Thanks and greetings,

Joerg

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

former_member184867
Active Contributor
0 Likes

isBound(sName)  takes sName as parameter. I think you need to check table.isBound('rows').

Former Member
0 Likes

Thanks, that's it!

... but I saw that unbindRows does not remove the binding from the model, so a ".refresh()" on the model causes all the old binding-requests again.

How can I reject a binding totally?

Former Member

Hi Jörg,

it seems you have to use the setModel() method also for removing a binding.

Take a look at the documentation.


setModel(oModel, sName?) : sap.ui.base.ManagedObject

  Sets or unsets a model for the given model name for this ManagedObject.

The sName must either be undefined (or omitted) or a non-empty string. When the name is omitted, the default model is set/unset.

So, this call should remove the previously bound model:


myTable.setModel();

Greets,

ben

avisheksharmacoder
Participant
0 Likes

Hi, I wanted to make a List Empty and actually used this solution. For this a new model is required, that has the same structure but with empty data.

Answers (4)

Answers (4)

avisheksharmacoder
Participant
0 Likes

Hi, if you know your model's array structure (like the array name, that contains all the JSON which is binded to the table), you can make such another Model, keep the same structure(just the array name, no need for JSON data).

Now, to remove the old binding, you can just set this empty Model to your Table, using the setModel() method.

In this way, your old binding will be removed completely.

Former Member
0 Likes

I cannot understand that each "bindRows" generates such binding garbage at the model.

I think it must be possible to the change a binding (f.e. new filters), without generating a new one.

My task is to display content in a table, which depents on the selected line of a list ....

so I call every row selection change of the list table.bindRows() with filters from the list.

At the end I have as many XHR requests as row selection changes of the list, if I refresh the model.

... there must be a right/better solution for this.

Former Member
0 Likes

... something like oDataMoel.updateBindings() is exactly what I'm looking for, but does not work for me - all previous bindings remain at the model.

If I remove the model by "setModel()", the table inherits the model from its parent, which is the same model.

I think I need a redefinition of the binding.

former_member184867
Active Contributor
0 Likes

May be you can try this ..

Step 1: mytable.unbindRows()

Step 2: oDataModel.updateBindings(true)