Regarding radiogroup Item

Hi Isomorphic,

                    {
                    valueMap:{
                            "1":"<b>aaaa</b>",
                            "2":"<b>bbbb</b>", 
                            "3":"<b>cccc</b>", 
                            "4":"<b>dddd</b>",
                            "5":"<b>eeee</b>",
                            "6":"<b>ffffff</b>"
                          },
                    name:"rdOption",
                    showTitle:false,
                    _constructor:"RadioGroupItem"
                    },
       The above RadioGroup consist of 6 selection Item.

       I need to hide one of the item say aaaa only. Plze help me out.

Thanks & Regards.

Varun & Team.

Call setValueMap() on the RadioGroupItem.

strange behaviour

hello,
I have something strange happening. I’m using version 6.5.

I have a RadioGroupItem, when I select a value, I have it to be in bold and the other options not. so I modify the ValueMap accordingly.
what is happening is when I modify the display value in the valueMap and I remove the ‘</b>’ at the end, the RadioGroup behaves strangely and when I select an option, another option is selected.
When I modify in anyway the string without removing a portion at the end, it works fine.

in the following code, click on ‘Phone’, then ‘Announcement’ and then on ‘Television’, ‘Phone’ is selected now!
Now, click on ‘Announcement’ repeatedly, the selection toggles now between ‘Phone’ and ‘Television’!

Then, comment the line ‘str = str.substring (0, str.indexOf (“</b>”));’ and try again, everything works fine.
(the problem is that the display value, even if not shown on screen, has a </b> at the end and if we have several clicks, the '</b>'s accumulate at the end)

<HTML>
<HEAD>
<SCRIPT>window.isomorphicDir='../isomorphic/';</SCRIPT>
<SCRIPT SRC=../isomorphic/system/modules/ISC_Core.js></SCRIPT>
<SCRIPT SRC=../isomorphic/system/modules/ISC_Foundation.js></SCRIPT>
<SCRIPT SRC=../isomorphic/system/modules/ISC_Containers.js></SCRIPT>
<SCRIPT SRC=../isomorphic/system/modules/ISC_Grids.js></SCRIPT>
<SCRIPT SRC=../isomorphic/system/modules/ISC_Forms.js></SCRIPT>
<SCRIPT SRC=../isomorphic/system/modules/ISC_DataBinding.js></SCRIPT>
<SCRIPT SRC=../isomorphic/skins/SmartClient/load_skin.js></SCRIPT>
</HEAD>
<BODY>
<SCRIPT>
isc.DynamicForm.create({ ID:"radioForm", width: 10,
values: {
	"value": "3"
},
fields: [
	{showTitle: false, name: "value", type: "radioGroup", vertical:false, valueMap: {
	"2": "Saloon","1": "Phone","3": "<b>Television</b>","4": "Announcement","5": "Emailing"
	}
	,changed: radioChanged
        }
]
});
	
function radioChanged (form, item, value) {
var labels = item.getValueMap();
    var str = "";
    for (var val in labels) {
        str = labels[val];
        if (val != value) {
	if (str.indexOf ("<b>") != -1) {
	   str = str.substring (3);
	   str = str.substring (0, str.indexOf ("</b>"));
	}
        }
        else
            str = "<b>" + str + "</b>";
    labels[val] = str;
   }
    item.setValueMap (labels);
    form.markForRedraw ();
}


</SCRIPT>
</BODY>
</HTML>

Follow-up

I’n IE, when I click on an option of the group and then set the valueMap as explained, I get a JavaScript error. The SmartClient console gives me the following message (I think is has to do with the focus lines since they do not appear in IE):
"
‘Demande d’accès à la méthode ou aux propriétés inattendue.’
in http://vulcain:8084/OA42x/isomorphic/index.jsp?skin=0
at line 1148
FormItem.focusInItem()
DynamicForm.focusInItem(_1=>[RadioItem ID:isc_RadioItem_154 name:$5401])
DynamicForm.$11b(_1=>[RadioItem ID:isc_RadioItem_154 name:$5401])
DynamicForm.$109(_1=>[RadioItem ID:isc_RadioItem_154 name:$5401])
anonymous(target=>null, eventInfo=>undef)
“appRecordEditLayoutRadioForm_01232709698_1444688254.$109(isc_RadioItem_154)”
Page.handleEvent(_1=>null, _2=>“idle”, _3=>undef)
EventHandler.$jw()
“this.idleTimer=null;var _1=isc.Page.handleEvent(null,this.IDLE);if(isc.Page.actionsArePendingForEvent(this.IDLE))this.startIdleTimer();return _1”
Class.fireCallback(_1=>Obj, _2=>undef, _3=>Array[0], _4=>[Class EventHandler], _5=>true) on [Class Timer]
Timer.$in(_1=>“$ir302”)
anonymous()
“isc.Timer.$in(‘$ir302’)”
"

Hi Gli
There are 2 separate issues here.
It appears we have a bug when setting the valueMap of a radioGroup in response to changed will reset values incorrectly in some cases.
Our developers have come up with a patch for this issue. To make use of this patch, include the following code in your file, after loading the SmartClient libraries. Note that this patch only applies to the 6.5.1 build and should be removed when you upgrade to subsequent SmartClient releases.

isc.RadioGroupItem.addProperties({

$20k:function(_1,_2){
var _3=this.itemCache[_2+"|"+_1];
if (_3) { delete _3._value }
if(!_3){var _4;if(this.itemPrompt){var _5=new RegExp("\\*","g");_4=this.itemPrompt.replace(_5,_1)}
var _6={type:"radio",name:"$540"+_2,value:_2,getElementName:function(){return this.parentItem.getElementName()},title:_1,prompt:_4,height:this.itemHeight,$8l:this.vertical,updateValue:function(){this.parentItem.updatePreviousSelection(this.value);return this.Super("updateValue",arguments)},shouldSaveValue:false};_3=this.itemCache[_2+"|"+_1]=isc.FormItemFactory.makeItem(_6)}
return _3}

});

The second issue is an IE only issue where in some cases a redraw of a focused item can trip a JS error. To workaround this, force a blur and re-focus, as follows:

function radioChanged (form, item, value) {
var labels = item.getValueMap();
    var str = "";
    for (var val in labels) {
        str = labels[val];
        if (val != value) {
	if (str.indexOf ("<b>") != -1) {
	   str = str.substring (3);
	   str = str.substring (0, str.indexOf ("</b>"));
	}
        }
        else
            str = "<b>" + str + "</b>";
    labels[val] = str;
   }
   item.blurItem();
   item.setValueMap(labels);
   item.focusInItem();
}

Please let us know if either of these workarounds don’t fix these issues for you

Thanks
Isomorphic Software

Hi,

  1. I applied the patch for the first issue and it works perfectly!

  2. As for the second, it’s better but it works when I click on all the options except the first one (‘Saloon’). When I click on it, I get the error. When I click on another option just after that, I get the error. Clicking then on another option (except the first) doesn’t give the error.

Thank you

Hi Gli
Sorry about that. Patching existing builds can sometimes be tricky and we missed that case.
Here’s a second patch to apply (in addition to the first patch) which should resolve the second issue:

isc.RadioGroupItem.addProperties({
    _rdn:isc.RadioGroupItem.getPrototype().redrawn,
    redrawn : function(){
       var itemCache = this.itemCache;
       for (var i in itemCache) {
           var item = itemCache[i];
           if (item.isDrawn() && (!this.items || !this.items.contains(item))) item.cleared();
       }
       return this._rdn();
    }
});

Let us know if this doesn’t do it!
Thanks
Isomorphic Software

hi,
perfect!

Thanks again