ComboBox in X++ - combobox

In my ComboBox there are items like A B C D and bydefault the value is A where i want to make it as C something like comboBox.comboType(2) in the init form, but this doesnt seems to work.
May be ComboBox.selection(2) helps, m not sure, Kindly help.

You can use this code in the form's init method after super():
ComboBoxName.selection(ComboBoxName::DefaultValue);
If this is a table field I'd suggest overriding the initValue method in the table:
this.ComboBoxName = ComboBoxName::DefaultValue;
Override initValue in the form's datasource only if it should be a specific behaviour in this form only.

All I did is overrided the initValue method of the form n wrote the code as tableName.ComboBoxName = ComboBoxName::DefaultValue;
And its working fine. Correct me if I am wrong :)

Related

Coldfusion array from form checkbox

I am trying to figure out the best way to handle this. I have a series of form fields with checkboxes for people to select options. When that gets submitted it turns form.optiongroups into an array. I then check to see if the id of the optiongroup is in the array and set the checked value to true in case there were form errors I want them to retain their checked value. This all works fine.
If I only select one option though it doesn't come through as an array, but just a regular form field. Is there a way I can handle this to make sure it is always an array?
Actually, checkboxes get submitted as a list. You must have something else going on that creates the array.
However, to answer your question as asked, you can use ListToArray(). It would be something like this:
if (structkeyexists(form, 'optiongroups') { // if no boxes are checked the variable will be undefined.
if (isArray(form.optiongroups) == false )
form.optiongroups = ListToArray(form.optiongroups)
} else {
code for no boxes checked
}
It could also be done via...
param form.optiongroups = "";
form.optiongroups = ListToArray(form.optiongroups);

Xpages Combobox -setting the default value

I have a combobox with values being populated from a managed bean like so:
keywordlist.setConnDB("jdbc:sqlserver://xx.xx.x.xx:1433;DatabaseName=xxx");
keywordlist.setConnUserName("xxx");
keywordlist.setConnPassword("xxx");
keywordlist.setSQLQuery("SELECT DisplayText as Keyword From Glossary WHERE SUBSTRING(DisplayText, 1, 2)= 'RV'");
keywordlist.keywords;
I'd like to be able to set the default to '--- Select ---', but no matter what I do the keyword list always picks the first of the returned keywords as the default.
Any assistance would be much appreciated.
Thanks,
Dan
Add another value pair (on first position), type "formula item" with the following SSJS return value:
"-- Select --|"
Notice the pipe!
That should display this at first position and should also be defaulted as "empty" is the default value. If not, set the "alias" (the value after the pipe) to something that you can define as default value porperty for the combo item.
It might be because you're binding to the bean directly. You might have to add that value to your keyword list itself. I think I have an example of this in a NotesIn9 show: http://notesin9.com/index.php/2014/03/13/notesin9-138-xpages-combobox-improvements/
I'm not sure. If I don't have a default in the java code you can probably see how it might be done.
Try that. If that doesn't work at all then maybe you don't bind the combo box to the bean directly. Maybe bind it to a viewScope var... since that can be anything it'll take a blank... then you just need to move the viewScope var value back up to your bean in the onChange event or something.
Just a quick thought...
Basically, the following pattern could be a start point for such a combobox:
<xp:comboBox
id="comboBox1"
defaultValue=""
value="#{document1.someField}">
<xp:selectItem
itemLabel="--- Select ---"
itemValue=""></xp:selectItem>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:
// Your SSJS code...
// Should return some kind of list...
return items;
}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
Alternatively, you can grab the keyword values from a Java bean:
<xp:selectItems value=#{yourBean.yourValue}></xp:selectItems>
Still, it's important to return a list value. It might also have "label|value" format.

Ext JS--How to make itemSelector values unselectable?

Inside my itemSelector's value config, I have set the values like so:
value:["A","B","C"]
A,B, and C are mandatory and thus cannot be deselected. How do I stop these values from being deselected?
Thanks
You can capture the beforedeselect event and return false for these items. It would help people answer question more appropriately if you post your code here.

Why is setting datagrid.Items.SortDescriptions(#).Direction giving an error?

I have a wpf datagrid that I want to sort programatically as if the user had clicked on the header. After some searching I found reference to using this:
datagrid_selected.Items.SortDescriptions(2).Direction = ComponentModel.ListSortDirection.Ascending
Looks like it would work. Intellisense says Direction is a getter and setter, but when I try to assign it to something I get the "Expression is a value and therefor cannot be the target of an assignment" error. By nature as a setter I should be able to assign this to a value, right? Any idea what's going wrong?
It appears as if SortDescriptions are boxed values.
Instead, try the following.
var sortDescription = grid.Items.SortDescriptions[0];
sortDescription.Direction = System.ComponentModel.ListSortDirection.Ascending;
grid.Items.SortDescriptions[0] = sortDescription;

Trouble referencing movieClips

I am working on a flash project that dynamically generates navigation from an XML. For now I am trying to get it to work with arrays so that I can adapt it to xml once I know the logic works. I am new to as3 and learning has been a tiny bit bumpy. I have been searching for a solution to this but many of the examples I have seen have either been too simple to answer my question or too complex to understand since I am on the new side. This is the code I am working with.
var clientList:Array = new Array("Client1","Client2","Client3","Client4","Client5","Client6","Client7","Client8","Client9","Client10","Client11","Client12","Client13","Client14","Client15");
for each (var cName in clientList){
var newClientBtn:btnClientNav = new btnClientNav();
newClientBtn.x = workX;
newClientBtn.y = workY;
workY += newClientBtn.height;
newClientBtn.mcClientName.text = cName;
lContent.mcWork.addChild(newClientBtn.name);
trace(newClientBtn);
}
I can't fingure out how to properly refernce the dynamically created clips. I have a dynamic text box in the button but can't figure out how to reference it properly to change it, then my next issue will be referencing the buttons to make rollover and click code. I know this probably something simple to fix but I have been looking at it for too long and my eyes are starting to cross.. Thank you in advance for any advice you can give.
Why not store the clips you are creating in an object you can access later?
If you want to reference a movie clip by name though, one way to do it is:
var referenceMC:MovieClip = MovieClip(containerMC.getChildByName(“targetMC”));
If it was a text field or a button you were after, I believe you would do the same but instead cast the result of getChildByName to your desired control.
I also believe you want to add the button itself as a child, not pass its name into your addChild call?

Resources