Can anyone suggest how I might add or remove (or show and hide) options in a segmented view at runtime?
I got there with the following code - a bit long winded but it works
if (numberOfviews == 1) { $$("viewtabs").hide(); };
if (numberOfviews == 2) { $$("viewtabs").show(); $$("viewtabs").define("options", [{ label: '1', value: 'view1' }, { label: '2', value: 'view2'}]); };
if (numberOfviews == 3) { $$("viewtabs").show(); $$("viewtabs").define("options", [{ label: '1', value: 'view1' }, { label: '2', value: 'view2' }, { label: '3', value: 'view3'}]); };
if (numberOfviews == 4) { $$("viewtabs").show(); $$("viewtabs").define("options", [{ label: '1', value: 'view1' }, { label: '2', value: 'view2' }, { label: '3', value: 'view3' }, { label: '4', value: 'view4'}]); };
If anyone can improve the code it would be much appreciated.
Hi,
your solution is correct. There is not better approach to change options in Segmented view than define method.