Oracle Apex checkbox - checkbox

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;

Related

DataGridView with DataGridViewComboBoxColumns fill Selection after sorting

I have a DataGridView which is bound to a SQL result. Afterwards I add three DataGridViewComboBoxColumns manually, which are populated by corresponding SQL results.
When choosing an entry from each of the DataGridViewComboBoxCells, the ValueMember is saved to the database.
As soon as the DataGridViewComboBoxColumns are added, a preselect function is called, which reads the selected values from the database, to always see the last state.
Until now everything is working as expected.
The problem is, as soon as I sort the DataGridView by clicking on any of the column heads, the DataGridViewComboBoxCells are not preselected any more.
So, I thought, by adding a .Sorted event handler which calls my preselect function would solve this problem. But the selection is not done any more.
function PreselectComboBoxes(int IdJob) {
foreach (DataGridViewRow row in dataGridViewHotels.Rows)
{
... // iteration through all rows and set value read from database by reading ID number from first column
}
}
As the ID for the database can be read directly from the row, I do not see, why it does not work this way.
Thanks in advance for any ideas.

Hiding empty values in SSRS report

I have SSRS report which has field with an empty values, based on yes/no parameter
When my parameter = No, this field appears as empty (no values)
When my parameter = Yes, this field has values
Please, see the images below -
"include Depreciation" Parameter = No,
"Depreciation" field is empty:
[![enter image description here][1]][1]
"include Depreciation" Parameter = Yes,
"Depreciation" field is NOT empty
My goal is to hide the row when the parameter = No (and field has no values)
I was trying the following in SSRS:
In "Design" view in the table, clicked on an entire row responsible for "Depreciation", Row Visibility, Visibility - "Show / Hide based on an expression", entered the following expression:
=IIF(Isnothing(Fields!GLGroupLevel2Name.Value),false,true)
But it does nothing... An empty row (in case if parameter = No) still appears.
Here is my "Design" view
(the row I modified with the conditional show/hide - is marked in grey):
Any suggestions or advice would be very helpful!
Thank you...
Try expression on Group Visibility.
If your condition is fixed then Go to Row Group Properties and Apply your same expression in Visibility option based on your condition.
Use Expression as:
=iif((Fields!YourFieldName.Value <> "") ,false,true)
As shown in below image
This should work.

Drop Down Parameter Not Returning a Value For a Query

I have a database set up which includes a query and a form, which are causing me problems. In the form, I have a drop down menu which allows you to select from a list of ID values (e.g. 1, 2, 3, ...). Once you have selected a value, you then click a button and it runs the query with a parameter of the ID number from the drop down ([Forms]![KitInfoRetrievalForm]![DropDown]).
The problem here though, is that when I select something from the drop down menu and click the button to run the query, it gives a pop up box asking for a value to substitute in for [Forms]![KitInfoRetrievalForm]![DropDown]. This leads me to believe that either the drop down menu is a null value for some reason or my pathing to it is incorrect.
This was working at one point and then stopped after a series of weird error messages from something else entirely (in the same Access project). Any help you can give me would be much appreciated.
I would recommend to replace reference to dropdown in query by function. It should eliminate this problem and also this is a workaround for old bug in Access, which exists in all recent versions: if the form/subform is in datasheet mode and you applied filter (quick filter thru user interface or using VBA), it stops reading variables with references to controls or just parameters and uses last used value.
I'm using this function for reading form/subform control value:
Public Function GetControlValue(strFormName As String, strControlName As String, Optional strSubFormControlName As Variant) As Variant
On Error Resume Next
If IsMissing(strSubFormControlName) Then
GetControlValue = Forms(strFormName).Controls(strControlName).Value
Else
GetControlValue = Forms(strFormName).Controls(strSubFormControlName).Form.Controls(strControlName).Value
End If
End Function
In your case replace [Forms]![KitInfoRetrievalForm]![DropDown] by
GetControlValue("KitInfoRetrievalForm","DropDown")

getting the selected item in select1 outside a repeat group

I am having some trouble implementing the relevants. I am suffering with getting the value of the selected item from my multiple select (the multiple select is outside the repeat group, the repeat group is where the implementation of relevant needs to be done).
I started off with a multiple select question ITEMLIST (readonly, all selected) outside a repeat group.
That limited my repeat loop (as intended) with the count of the selected items in the list (count-selected(/data/ITEMLIST))
I need to use the selected value of the first item(outside the repeat group) in the first repeat loop and so forth for all other iterations (managed to get the position - selected-at(/data/ITEMLIST, position(..)-1) and label - jr:choice(....) of the items in each iteration)
questions inside the repeat loop have relevants that if the item selected in the ITEMLIST is 1 then it needs to be shown else skipped, sth like.
I did some searches but could not implement anything.

Dynamically put checkboxes on form

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).

Resources