Hi,
I have a new form that I have created in the SM. I created a combo box on that form and need to attach an onDataChange method to it. I can’t figure out the correct syntax and haven’t found an example on the forum.
I tried a few variations but couldn’t get anything to work. The method I am trying to attach is a global method called “item_type_filter”.
Here is one example of what I tried.
var frmobject2 = myForm.newComboBox(globals.g_active_item_type,110,51,206,30) //combo box
frmobject2.onDataChange = globals.item_type_filter();
Thanks!
Hi monetteboy,
Since the onDataChange property is of type JSField, I would try creating or getting such an object first and then attach it.
Like so:
var mtd = solutionModel.getGlobalMethod("item_type_filter");
frmobject2.onDataChange = mtd;
Hope this helps,
Thanks for the tip.
The form loads correctly now, but the method doesn’t fire.
I will play around with it some more but if you or anyone has any other thoughts that would be great!
Thanks again!
—UPDATE—
I found the method fires if I set the onFocusLost or the onFocusGained.
It does not fire if I set onDataChange or onAction.
Just wanted to post that I was able to get this working.
I had to change from using
var frmobject2 = myForm.newComboBox etc
to
var jsfield = myForm.newField(‘globals.g_active_item_type’,SM_DISPLAYTYPE.COMBOBOX,95,51,140,30)
then used
var mtd = solutionModel.getGlobalMethod(“item_type_filter”);
jsfield.onDataChange = mtd
I am not sure what the difference is between using the “newComboBox” and using “newField” with a type of Combobox, but at least it works.
Thanks for push in the right direction.
Glad to know it works!
But the difference between setComboBox and setField looks like a bug, IMHO.
You should post a bug report to the support system with a sample solution to help the Servoy engineer reproduce this inconsistency.
Yes, please create a case in our support system for this, with a small sample solution if possible
Paul
No problem I will try to get that done today.
Thanks!