I have a grid called myGrid. The column A of myGrid is a lookup that shows 2 values: the code, and the description.
I would like to copy the selected item's description into a second column of myGrid.
What would be the best way to do this?
I have encountered this sometimes ago and the solution I found is a bit complicated but works fine.
I had to create a form from scratch which is currently used in the lookup.
When calling the form in the lookup() method, don't forget to put "element" in the arguments.
In the init method of the new form, use element.selectMode(YourTable.Code) to specify which field will be selected. Override the closeSelect() method of the new form and make it call a parm method located in the caller form. This parm method will set the YourTable.Description field of the current record. Send the Description related to the record from YourTable selected by the user in the lookup.
The new form should be a window of type Popup, with the toolbar hidden and always on top. Its datasource should be YourTable.
Call the new form from the lookup method (or better, from a method at the table level called from the lookup method) using ClassFactory.formRunClass(args).
I found a 'simple' solution: i've to simply override the method modifieldfield
Related
In App Maker, what is the simplest way to achieve the same result with a dropdown box that you can with a suggest box, which can return the whole record when you make a selection giving you the ability to assign associated record values to other fields on the page?
Consider a data model with three fields, (Code, Description, and Severity). Add a dropdown box to select the Code. Have the selection, (probably using onValueChange or onValueEdit), write the selected Code's Description to a label field beside the dropdown box. The Code's Severity will also be used to affect the style in some way like background color or something, but for this answer, merely assigning the value to a scripting variable will be good enough. It's the record value access and assignment mechanism I am after.
Clarification: This data model will not be the page's datasource. It is a secondary reference table used for assigning a code to a ticket. You can also assume that a record value will be written to a field in the page's datasource as well.
I would appreciate the simplest low code solution as we will have non-programmers attempting this. Thanks.
As long as you leave your value binding on the dropdown blank the following should work:
Set the options binding to:
#datasources.YourDatasource.items
You may want to consider changing the 'Names' binding to be the projection of a particular field in this datasource otherwise the values showing in your dropdown will only be the 'keys' from this datasource.
Then in your onValueEdit event you will gain access to individual fields like this:
var item = widget.datasource.item;
item.YourFieldToEdit1 = newValue.YourOtherDatasourceField1;
item.YourFieldToEdit2 = newValue.YourOtherDatasourceField2;
That would probably be the simplest way.
I am (still) working with Vaadin 7.6.4 and im trying to write my own custom FieldGroup.CommitHandler
I am trying to retrieve the currently added item (grid row) from the the commitEvent itself.
While debugging I can see that all the Data is available in a property called itemId if I use the following trainwreck: commitEvent.getFieldBinder().getItemDataSource() inside the Debug-Inspector, however it is private.
The itemId is the exact bean-entity i want to access. I only managed to access single fields of the entity with the following trainwreck: commitEvent.getFieldBinder().getField(propertyId).getValue(). However this is cumbersome and does not give me the entity as a whole (and to be precise does not retrieve the information from the entity, but rather from the displaying elements of the grid).
Is there a way to access the currently edited entity (which is the datasource for the edited grid row), without declaring the entire grid as a global field and call the grid.getSelected()-method?
Also, is there a data-wise difference between post- and preCommit?
Since you are apparently using BeanItemContainer based on your comment of itemId, You could try something like the following:
BeanItem item = (BeanItem) commitEvent.getFieldBinder().getItemDataSource();
MyBean bean = (MyBean) item.getBean();
getBean() in this case returns itemId.
I need to create an EDT that will use DimnesionValuesLookup.
So I've made an EDT with reference to my View that has DisplayValues for my specific dimension type, also I set formHelp property as DimnesionValuesLookup. And when I'm trying to open lookup on query search criteria I get an error:
Form should be called with parameters
I looked into the Init() method of DimnesionValuesLookup and found out that I need to pass DimensionAttribute as a record.
How can I do this?
Your comment did not answer my question, but I'm assuming you have a way to identify the name of the attribute for which you want to lookup values. Using the name you can select the DimensionAttribute record that you need to call the lookup form by using the findByName method of table DimensionAttribute. After that you can call the lookup form. Standard AX does something very similar in form DimensionValueInterval, take a look at the lookup method there.
I want to use model values on view page but in shortcode way?
For Example:
#model.name prints name which is assigned to model by controller.
But I want to use it with out #model.name by another token or shortcode?
For example now we use #model.Name for print its value on view page but I want that value with out using #model.Name.
I want to use another token which can print the same value of it.
I have found a solution; I can use tuple with view bag.
A view bag is a dynamic object using session, so make a tuple and then pass it to view.
I have a form where user picks a Item# and gets info for the selected Item. This form got enhanced by adding another filter, using a combobox control, to select a 'warehouse'.
I could use a lookup for the warehouse(the list is huge) to chosse a 'warehouse' but what am trying to do to query warehouse on Item# value and populate into combobox.
Tried to attached a screen shot, unfotunately, the system doesn't let me do it. If I need to put more details, please let me know.
Is it doable?
I would suggest you to do this with a temporary table. Create one in AOT, and declare it as global variable in your form.
When Item (datasource field or design control, choose what's more accurate for you) is modified, just delete table content, and fill it at your needs.
In the control lookup method, call temporary table lookup method, i.e. "static void lookup(TMPTable _tmpTable)". Do a SysTableLookup, with a standard query over TMPtable, but it's important to use QueryBuildDataSource.setCursor(_tmpTable) (I don't remember now where was method setCursor() in Query or QueryRun, search for it a bit).