I've got following problem using SmartGWT 2.4:
we are having a DynamicForm showing several static text fields (so the form is in readonly mode). The form uses a datasource in the background and our own FormItemFactory to create proper form items based on our meta data. Some of the form items contain boolean values displayed as strings: like 'isHidden': false or 'canShow': true.
by user action (button click) we need to switch the form to edit mode.
We do it in following way:
we first gather the form values as rec = form.getValuesAsRecord() getting a Record object
then we create a new dynamic form and set into it the same datasource as original has
then we call the newForm.editRecord(rec) method of newly created dynamic form
This way the form static values are shown as editable input fields. However the problem is with those boolean values. They are correctly transformed into check boxes but all of them are checked by default.
I think that the string values 'false' or 'true' are not parsed into boolean values and set as value for respective check box item.
Can I somehow influence this process? I tried to provide an anonymous implementation of FormItemValueParser to CheckboxItem but it turns out to be use only by free text form items.
I'll be really thankful for any given hint.
Try setting the value explicitly to the formItem with record.getAttributeAsBoolean("formItemName")
BooleanItem boolItem = new BooleanItem("boolname");
DynamicForm form = new DynamicForm();
form.setItems(boolItem);
//Get record
Record rec = form.getValuesAsRecord();
boolItem.setValue("boolname",rec.getAttributeAsBoolean("boolname"));
Related
I have a page within my app with a Checkbox option.
The idea is basically to allow the user to select/unselect it if the change needs to be applied for every Sales Rep.
Something like this:
If checkbox is clicked = Change would be applied to all territories owned by the Rep
If checkbox is not clicked = Change would only be applied to the selected territory
I can't seem to get the checkbox clicked option to work.
I'm using an instr function to get a value out of it but it doesn't work:
select instr(':' ||:P11_CHECK_FOR_ALL|| ':', 'Request') into v_number_terr from dual;
if v_number_terr >0
(P11_CHECK_FOR_ALL is my checkbox Item / 'Request' is a word that's part of its label)
my checkbox pic
I'm trying to capture (in a process) whether the option is checked or not.
Could someone give me a hand please?
Thanks!
In apex a checkbox behaves just like a select list (with multiple selects possible). There is a display value and a return value. If nothing is selected, the page item value will be null. If one or more value are selected, the page item will contain a colon separated list of selected return values.
To handle the select list in a page process, the easiest is to split up the colon separated list in individual values using APEX_STRING.SPLIT
Example (untested):
DECLARE
l_check_for_all apex_t_varchar2;
BEGIN
l_check_for_all := apex_string.split(:P11_CHECK_FOR_ALL,':');
-- loop through the values. If nothing is selected then the COUNT will be 0 and nothing will be executed.
FOR i IN 1 .. l_check_for_all.COUNT LOOP
// do your pl/sql magic. You can reference the current item with l_check_for_all(i)
END LOOP;
END;
How can I get the complete selected text from an AutoComplete TextField?
If I use getText(), I only get the few letters the user has input so far.
Example: I write "flo" and then select "Flowers" from the list, but getText() gives me "flo"
AutoCompleteTextField auto = new AutoCompleteTextField(arrayWithNames);
auto.setMinimumLength(4);
auto.addListListener((ActionEvent evt1) -> {
String lookedFor = auto.getText();
Hashtable<String,Object> match[] = findMatch(lookedFor);
if(hMatch.length>0){
contElements.removeAll();
for (Hashtable<String, Object> Match1 : match) {
...
...//fill the Container with the names found
...
}
}
});
How it works
I am using the AutoComplete TF as a search button.
I have an array with all the names in my list.
Then I populate the Auto with the array.
The user selects a name from the Auto and then I search the value that is being "lookedFor" using the findMatch(). It returns a new array with the found entries.
I need the complete name from the list so I can use the findMatch() method, but when I use getText() from the Auto, it only returns the letters the user entered, and not the whole name, so my method does not work, since I am comparing whole Strings.
(I am using the Auto because it is very convenient if people remember only a part of the name they are looking for)
If you subclass AutoCompleteTextField you can access the selected text internally via getSuggestionModel().getItemAt(getSuggestionModel().getSelectedIndex()). Now you can define a public getter method getSelectedText() or something on your derived class.
I am not sure you are using the AutoCompleteTextBox correctly.
The entire purpose of the AutoCompleteText box is to help you assist the user in selecting from a list of valid requests,
You should not be getting the value of getText() until the user is ready to submit the form where the AutoCompleteTB is located.
This WILL help if you haven't already looked here:
https://www.codenameone.com/javadoc/com/codename1/ui/AutoCompleteTextField.html#getPropertyTypes--
Good luck!
In NETSUITE
is there any way to access to a value inside of a combo-box at the item line level?
I need to access to a value after inserting an item but all functions get me null value.
I have tried
nlapiGetCurrentLineItemValue
and
nlapiGetFieldValue
Both functions are getting me null values.
Thanks,
Pablo.
In general (for user event and client script) below code should work
nlapiGetLineItemValue(LINE_ITEM_TYPE, YOUR_FIELD_ID, LINE_NUMBER);
eg on SO to get the line item Id:
nlapiGetLineItemValue('item', 'item', 1);
PS: Syntax is independent of data type or field type
If you mean combo box as a mulitselect, and if you're trying to access via User Event Script, use:
nlapiGetLineItemValues(type, fldname, linenum);
Note the 's' in nlapiGetLineItemValues
If its just a standard field, nlapiGetLineItemValue(type, fldname, linenum) should work.
Which call to use depends on what event you are capturing.
For instance if you are trying to access the value in a post sourcing, field changed or line validate event of a client script you would use nlapiGetCurrentLineItemValue('item', 'fieldname');
I have a table in DB with information about some goods. Goods may be fillable, so we can add text to it. So I want to dynamically generate a list of checkboxes related to info in table and even some checkboxes must be with TEdit component to make a possibility to add text to this item. So how can I do it? What component should I use? I figure out that TTreeView is almost enough, but it doesn't allow to "draw" TEdit near checkboxes. I'm using Delphi 2010. Thanks in advance! Hope for your help!
If I read your question correctly, you would like to create some controls on a form based on the contents of table. In the following example I have assumed you want to do this based on the contents of the current record in a TDBGrid, so you'll have to adapt as needed.
The example assumes a form with a TDBGrid and a TPanel (Panel1) that will hold the controls created at run time.
The TDBGrid will be connected to a TDataSource component and that will be connected to some TDataSet descendant for the table/query with the information. The TDataSource has a OnDataChanged event. This event gets triggered when the data in a field changes or when the current record in the dataset changes. So you can use that to change the controls as the current record changes.
procedure TForm1.DataSource1DataChange(Sender: TObject; Field: TField);
var
i: Integer;
Chk: TCheckBox;
Edit: TEdit;
begin
// When the Field is assigned, the call is the result of a change in the field.
// When the Field is unassigned, the call is the result of changing the current record.
if Assigned(Field) then
Exit;
// Remove controls on panel
for i := Panel1.ControlCount - 1 downto 0 do
Panel1.Controls[i].Free;
// Add controls on panel for current record
if True then // Replace this with condition based on contents of current record (if any!)
begin
Chk := TCheckBox.Create(Self); // Set Owner, so it is freed when form is closed.
Chk.Parent := Panel1; // Set Parent, so the control is shown.
Chk.Left := FLeftIndent; // Create FLeftIndent as a member field of the form, set value in OnCreate.
Chk.Top := FNextTop; // Create FNextTop as a member field of the form.
Inc(FNextTop, FSpacing); // Create FSpacing as a member field of the form, set value in OnCreate.
if True then // Replace this with condition that dictates creation of Edit
begin
Edit := TEdit.Create(Self);
Edit.Parent := Panel1;
Edit.Left := Chk.Left + Chk.Width + FSpacing;
Edit.Top := Chk.Top; // Add offset as needed for proper alignment of CheckBox and Edit.
end;
end;
end;
Please note that if you do not have any other checkboxes or edits on the form, you will have to include the proper vcl units yourself. The easiest way to do that is to drop them on the form, save the form and then delete the controls again.
try this example about creating checkbox on runtimehpe it helps you will have to modify the position dynamically. you can either create a new component wich includes checkbox with Edit on it or create the TEdit dynamically where you need it.
Consider creating an array of TCheckbox and one of TEdit and set the visible property of each Edit using something like IsEditNeeded boolean function in which you code the conditions if an Edit field is needed.
I would be tempted to use a gridview like ExGridView, and let it draw my checkboxes, and do the "edit" controls for each row, for me. However, if you really want an edit box, instead of a grid, you could also try a control-grid approach (1 checkbox + 1 edit control, in a control-grid).
This drives me crazy:
i'm using a datagridview (bound to a dataset) and textboxes also bound to the dataset (which means that everything typed into the textboxes is reflected in the datagridview). The datagridview is actually used only to show up the values (user is NOT able to edit anything in the cells).
So: when the user pushes the add new record button (automatically created by visual studio using binding navigator etc. ) i would like to programmatically select this new line (remember: user has not the ability to select with the mouse) and insert some values.
I tried to use the
DefaultValuesNeeded
event, but this is firing only if the user selects the row with the asterisk indicator (what the user is not allowed to do).
How can i simulate that behavior? Should i take another approach?
Thanks in advance!!
Was searching for alternatives to how I currently do this and just wanted to let you know about a couple ways I know of. Both of these will set defaults when using the * (new row) or using a BindingNavigator.
private void CityBindingSource_AddingNew(object sender,
AddingNewEventArgs e)
{
// Simply set the default value to the next viable ID,
// will automatically set the value when needed.
locationDataSet.CITY.CITY_IDColumn.DefaultValue =
CityTableAdapter.GetNewID(); // ++maxID;
}
Or
private void CityDataGridView_DefaultValuesNeeded(object sender,
DataGridViewRowEventArgs e)
{
// Gets called when datagridview's */NewRow is entered.
e.Row.Cells[0].Value = CityTableAdapter.GetNewID(); // ++maxID;
}
private void bindingNavigatorAddNewItem_Click(object sender,
EventArgs e)
{
// BindingNavigator button's AddNewItem automatic tie-
// in to bindingSource's AddNew() is removed.
// This sets the current cell to the NewRow's cell to trigger
// DefaultValuesNeeded event.
CityDataGridView.CurrentCell =
CityDataGridView.Rows[CityDataGridView.NewRowIndex].Cells[1];
}
I was really hoping to use this:
private void CityBindingSource_AddingNew(object sender,
AddingNewEventArgs e)
{
// Cast your strongly-typed
// bindingsource List to a DataView and add a new DataRowView
DataRowView rowView =
((DataView)CityBindingSource.List).AddNew();
var newRow = (LocationDTSDataSet.CITYRow)rowView.Row;
newRow.CITY_ID = CityTableAdapter.GetNewID();
newRow.CMMT_TXT = "Whatever defaults I want";
e.NewObject = rowView;
}
But when adding using the BindingNavigator or any code based bindingSource.AddNew() it results in just a blank row. Hopefully someone finds a better way, but this is working for me so far.
Revised:
How about the Datatable's TableNewRow event, then? If that gets fired when the BindingNavigator creates a new row, then that's an opportunity to populate the object.