cancel
Showing results for 
Search instead for 
Did you mean: 

disable sap.m.List

former_member202465
Contributor
0 Kudos

Hi,

What is the way to disable a sap.m.List? Such that we can't select / deselect items, etc.

Thanks

Udi

Accepted Solutions (1)

Accepted Solutions (1)

saivellanki
Active Contributor

Hi Ehud,

You mean something like this? JS Bin - Collaborative JavaScript Debugging

Regards,

Sai.

former_member202465
Contributor
0 Kudos

Hi Sai Vellank,

Yeh - this is exactly the solution I'm familiar with. Notice how the "View Mode" does not reflect the recent selections

I will try to go for the Overlay idea.

Thanks!!

saivellanki
Active Contributor
0 Kudos

Ehud,

How about this one? JS Bin - Collaborative JavaScript Debugging

Just a hack!

Regards,

Sai.

former_member202465
Contributor
0 Kudos

Hi Sai Vellanki,

Thanks for your honest efforts

and it works... super!

Thanks

Udi

former_member202465
Contributor
0 Kudos

Hi,

I revised the solution a bit - see below. This way we need to set the list once after each rendering. We don't have to respond to change events.

Again, thanks Sai Vellanki.

Code taken from the Control that generates the List:

var list = new List({

  ...

  includeItemInSelection: "{/enabled}",

  ...

});

list.onAfterRendering = this._listAfterRender.bind(this);

...

_listAfterRender: function(event){

  var list  = event.srcControl;

  var model = this.model;

  var enabled = model.getProperty("/enabled");

  var items = list.getItems();

  for (var i=0; i<items.length; ++i) {

    var item = items[i];

    var multiSelect = item.getMultiSelectControl();

    if (multiSelect) {

      multiSelect.setEnabled(enabled);

    }

    var singleSelect = item.getSingleSelectControl();

    if (singleSelect) {

      singleSelect.setEnabled(enabled);

    }

  }

},

...



Enabled:

Disabled:

Answers (2)

Answers (2)

former_member202465
Contributor
0 Kudos

Hi again,

Maybe the solution is to use the m.Table and set the showOverlay to true (for disable).

like your opinion...

Thanks

former_member182862
Active Contributor
0 Kudos

Hi Udi

here is an example

JS Bin - Collaborative JavaScript Debugging

You can set the list mode to sap.m.ListMode.None

Thanks

-D

former_member202465
Contributor
0 Kudos

Hi Dennis Seah,

Thanks for the quick reply!


I'm familiar with this option. Unfortunately I can't use it: I need to show View / Edit mode for the same UI - view should present all the info, just not editable.

in ListMode.None we don't see what items are selected...

Thanks!