Skip to main content

dojo dijit combobox vaule

4 replies [Last post]
gbvillavicencio
Offline
Joined: 2009-05-06
Points: 0

Hi Guys,

I hope you could help me with this one... Here goes:

Assuming that we have the following codes...

When we select ' Texas' , the combobox passes the value ' Texas '...
What I would like to know if it is possible to have ' TX ' as value of the combobox

Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
gmurray71
Offline
Joined: 2003-07-31
Points: 0

Hi,

When I look at the /resources/dojo/dijit/combobox/component.js I'm seeing from line 190:

var _val = _getValueMapping(targetId);
if (_val) {
processActions(publish, _val, _val.targetId, 'onSelect', _val);
var _item = _widget.store._getItemByIdentity(targetId);
_widget.wrapper.setValue(_item.label);
}

Basically this should be returning the value by default.

I'd suggest you could do something like:

var _val = _getValueMapping(targetId);
if (_val) {
var _item = _widget.store._getItemByIdentity(targetId);
processActions(publish, _val, _val.targetId, 'onSelect', _item);
_widget.wrapper.setValue(_item.label);
}

Which should publish a value with more attributes on it.

What version of the comboboxs are you using?

You can find out by looking at the top part of :

/resources/dojo/dijit/combobox/widget.json

-G

gbvillavicencio
Offline
Joined: 2009-05-06
Points: 0

Hi Greg,

Thanks for your reply, I tried the code you've posted, and it seems that it has the same result. The only available attributes in args is widgetId and value (which is still the label of the object)

Im using version 1.8.1 of dojo.dojit.combobox.

Thanks again

Message was edited by: gbvillavicencio

gmurray71
Offline
Joined: 2003-07-31
Points: 0

Hi,

After a little digging into the dojo source (and my own) I found some code that will work.

Near the end of your component.js file (around line 344) there is a function :

this.onChange = function(value) { ....

}

Change the function to be:

this.onChange = function(value){
var _item = { label : value,
value : _widget.wrapper.item.val[0]
};
jmaki.publish(publish + "/onChange", { widgetId : wargs.uuid, value: _item});
};

Now you will get the value and the label published.

Regards,

-Greg

gbvillavicencio
Offline
Joined: 2009-05-06
Points: 0

Thank you very much Greg....

The code works fine... (just added a [i].value[/i] to _item for it returns object)

[i]
jmaki.publish(publish + "/onChange", { widgetId : wargs.uuid, value: _item.value });
[/i]

I've been stuck on this for days...

your help is very much appreciated...

Thanks again...