Currently I have a table which contains input from users, and these input will be shown in a Form.
The case is, I am able to show checkbox in the form manually but as the input from users grows, I need to have the checkbox to be generated automatically. Is there any way to achieve this in X++?
There no restriction whether the checkbox is lined horizontal or vertical, it's just it would be nice if it can be shown as columns.
I wanted to make the checkbox generated automatically so when Table_A have inputs, I don't need to insert a form manually.
This is so when I look at Stall 1, I know what menus it is selling.
As mentioned by FH-Inway, you need to create additional table e.g. Table_ATable_BRelation. Please find below code to add controls dynamically:
form = formRun.form();
design = form.design();
grpCtrl = design.addControl(FormControlType::Group, #GroupControl);
while select Table_A
{
idx++;
Table_ATable_BRelation = this.findOrCreateRelation(Table_A, Table_B);
chkBoxCtrl = grpCtrl.addControl(FormControlType::CheckBox, strFmt("CheckBox%1", Table_A.ID));
chkBoxCtrl.label(Table_A.Food_Menu);
chkBoxCtrl.labelPosition(LabelPosition::Above);
chkBoxCtrl.helpText(strFmt("your text here %1.", Table_A.Food_Menu));
chkBoxCtrl.value(Table_ATable_BRelation.IsSelling);
chkBoxCtrl.registerOverrideMethod(methodStr(FormCheckBoxControl, clicked),
methodStr(ClassHelper, checkBoxClicked),
this);
}
grpCtrl.columns(idx);
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.
In Google App Maker, I have several widgets on a page.
One of these widgets is called Label12 (shown in Screenshot 1).
It definitely exists and is also shown in the breadcrumb trail at the top of my screen.
However, when I attempt to reference Label12 in my code, it does not seem to exist.
If I use the ctrl+space code completion helper, the Label12 widget is not shown as an option (shown in screenshot 2).
When I attempt to code it manually (e.g. app.pages.Reconciliation_Details.descendants.Label12.visible) it returns the error "Cannot set property 'visible' of undefined".
Why can App Maker not see Label12?
Screenshot 1 showing Label12 on page:
Screenshot 2 showing absence of Label12 when coding:
App Maker can see Label12. The point is that the label is inside a table widget, hence according to the documentation:
Because a table is a collection of other widgets, you can't use the Widget API to interact with a table. However, you can use scripts to manipulate the individual widgets that make up a table.
The above statement makes sense because the amount of rows a table will display depends on the datasource items; i.e., the rows are dynamically created when the widget datasource is loaded in the ui. Therefore, in order to access the label you need to first access the children of the Table1Body, which is a collection of named values known as PropertyMap.
I believe you are trying to hide/show that specific label based on some logic. The correct way of doing it would be something like this:
var rows = app.pages.Reconciliation_Details.descendants.Table1Body.children._values;
for(var i=0; i<rows.length; i++){
var row = rows[i];
var label = row.descendants.Label12;
label.visible = true; // or false
}
I am able to show the data source data in google app maker table widget, but I don not know how to show static values (array of object) to table widgets programmatically.
I am new to app maker,I don not know is it possible to add values to table widget programmatically or not.
If any one knows please help me...
Thank you in advance :)
To call your own create children method you would want to set up a panel similar to the picture provided and set a datasource for that panel for which items you want to appear in that panel.
Then go to events for that panel and in the onDataLoad event enter the following code as it pertains to your own data. In my example I used a datasource called employees, and I created a label with the employee name for each item in the datasource.
widget.datasource.items.forEach(function(item) {
var node = document.createElement('div');
node.className = 'app-Label';
node.style.margin = '8px';
node.textContent = item.EmployeeName;
widget.getElement().appendChild(node);
});
That is about the simplest example I have. In the case of a table you would want to create your own base container, a header, and then a container that holds all your table rows. Then in your table body you would set up a similar script that attaches row panels and in the row panels you would create your labels. This would also be possible to declare your own array of objects and loop over each object this way.
I have Form1. I have table "Category", now I want to display all CategoryName in to combobox cbbCategory in Form1, the category names data are retrieved from Category table, how can I do this?
There are several ways you can do this, from querying the table into an array, writing as a SQL query, etc and setting up the properties.
What I would suggest for a start is this. Open your form.
Right-click anywhere in the form and pick "Data Environment".
If the category table is NOT already shown in the window, right-click and select Add. It will prompt you to pick a table and select your category table. Then close the data environment.
Now, put a combobox on your form if you have not done so already.
Right-click on the combobox and click "Builder". It will walk you through the selection process to get what you want. Start with picking the table... your category table. Then it has picker next to it to identify which column(s) you want to be displayed in the combobox. If your category table has both an ID and a description, I would pick your description FIRST, then the internal ID column second (so we can hide the second column if you dont want to actually show it).
Click on the second tab for "Style", and to clarify the difference between a "Drop-down Combo" vs "Drop-down List" is that a combo will default show you available choices, but if one is not available, allows a user to manually enter a new one which you might want to allow adding to your master category lookup table. "Drop-down List" is fixed to only allow the user to pick an entry from those available and nothing else.
Next, click on the Layout tab. This allows you to adjust the columns widths to see/hide what it will look like during drop-down mode (just stretch/shrink the columns)
Finally, the "Value" tab. It is asking for which column from those you selected to be available do you want to store behind-the-scenes. If an ID column, so be it... if the description, that's fine too. You can leave the last "Field Name" blank for now and it will just store whatever is selected into the comboboxes "Value" property... from which you can do whatever you need to in next phase of you app.
I'm trying to implement multiple record selection feature on a grid.
It is very similar to http://www.tek-tips.com/faqs.cfm?fid=3831
It adds an extra column with check boxes. I want those check boxes!!
But it depends on a extra logical field in the underlying table. It need to create a class clscheck which inherits CHECKBOX. I'm not sure why this CLICK procedure is needed for the checkbox.
PROCEDURE CLICK
IF DODEFAULT()
KEYBOARD '{DNARROW}'
ENDIF
ENDPROC
When I removed it, row selection did not work correctly as expected. Why this?
Here is my requirement:
1) I don't want to add an extra logical field in the underlying table.
2) To work with controls in the grid, I think AllowCellSelection must be .T. I want AllowCellSelection = .F. because I don't need to work with any control in the grid except the check boxes. I need to work only with check boxes. The other columns will be read-only.
3) Can I have selected list without the logical field in the underlying table?
4) Can I remove the usage of KEYBOARD '{DNARROW}'?
In fact, I have a grid which is AllowCellSelection = .F., but it only provides single selection.
I need to enhance it with multiple selection, thus, I just want to add an extra column with check boxes so that user can know he can select multiple records.
No need Shift+Click or Ctrl+Click which is not familiar with idiot users.
I have found this - http://www.tek-tips.com/faqs.cfm?fid=433
It also depends on an extra logical field and it depends Shift+Click and Ctrl+Click.
What you are seeing is quite common for multi-select grids. I've used them SIMILAR to this in the past. However, you are afraid of the extra column in the underlying table. That may/not be true. You don't always have to update the ORIGINAL table, but a temporary CURSOR you are presenting to the user. Ex: If you want to display a list of employees in a table. No, you don't want to keep adding this column to the original employee table as then anyone else trying to do multi-select could falsely get your selection. However, if you pulled into your own local cursor and presented to the user, then no problem. Example...
Thisform.YourGrid.RecordSource = "Employees"
(bound directly to your employee table -- not necessarily the right thing)
vs
use in select( "C_MultiPickEmployees" )
select ;
.F. as IsChosen, ;
E.* ;
from ;
Employees E;
into ;
cursor C_MultiPickEmployees READWRITE
Thisform.YourGrid.RecordSource = "C_MultiPickEmployees"
NOW, you have your extra column without dealing with issues to the underlying table. If you wanted to further filter what you were showing -- such as employees for a certain division/department, then just add that to a WHERE clause, add an Order By if so needed and you are good to go.
As for the "Allow Cell Selection", I've never had to deal with that. I just add a "checkbox" to the first column and set
Thisform.YourGrid.Column[1].CurrentControl = "CheckBoxControl"
(based on the name it is added to the column).
Then, set the column 1's "ControlSource" = "C_MultiPickEmployees.IsChosen" and you should mostly be done.
As for the "CLICK" event trying to force the down arrow. This is more for automatically scrolling to the next record so you can just click, click, click for multiple entries.
Hope this helps clarify things for you.