igCombo Resets the text value after loading new dataSource - infragistics

I am using Infragistics igCombo in my implementation. When the user inputs 3 letters, I fetch the data and load in the dropdown list by calling the dataSource method. After loading the data in the igCombo dropdown, the already input text by user is deleted automatically and the combobox shows empty string

If you set allowCustomValue: true to the combo, then the input text should remain after a rebind.

Related

Display Only vs text fields with "Disabled" attribute set to YES

I am using APEX 21.2.
The help says that "Display Only" Items do not store session state value and text fields with "Disabled" attribute set to yes do. But I tried to create an after header computation and set the value of a display only item and it worked. Is it wrong information or am I missing something?
Disabled
Specify whether this item is disabled, which prevents end users from changing the value.
A disabled text item still displays with the same HTML formatting, unlike an item type of Display Only, which removes the HTML formatting. Disabled text items are part of page source, which enables their session state to be evaluated. Conversely, display only items are not stored in session state.
I tried to create an after header computation and set the value of a display only item and it worked
Why wouldn't it work? It is you (a developer) who set it using a computation (which works), but end user can't modify its value as it is set to be display only so - users can just look at item's value.
A computation before rendering is always possible, that has nothing to do with session state. This is about how the item behaves on page submit.
With the "Display Only" item type you can control its behaviour on submit. Behaviour is the same for "Text Field" items that have the "Disabled" property set to on.
I did a quick test with a form on the EMP sample data set. Create a after header computation of type expression :P1_SAL + 1.
Test 1: Setting "set on page submit" on. The form renders with the salary item increased by 1. When page is saved, the new salary is saved for the record
Test 2: Setting "set on page submit" off. The form renders with the salary item increased by 1. When page is saved, the new salary is NOT saved for the record
Where did you see this help text ? I don't see anything about session state.

How get display value of checkbox in a checkbox group?

I am using APEX 21.1. I have a checkbox group whose list of values is retrieved using a query...
select disease, id from history;
The query returns many checkboxes. I have another textarea item. I need to get the display value for any checkbox whenever it's checked and set item HISTORY to that value. How to do so?
Describing a how-to would be so much easier if you had provided some example page item names and example data. So, lets call your checkbox group P10_CHECKBOX and your textarea P10_TEXT.
Usually, your checkbox group will save the item ids as a colon seperated list, like this: 3:4:5
To display the corresponding display values, make a dynamic action on change on your item P10_CHECKBOX.
Then, use an action of type Execute PL/SQL Code to fetch the display values of your items.
The code could look like this:
select listagg(disease,chr(10)) within group (order by disease) into :P10_TEXT
from history h
join table(apex_string.split_numbers(:P10_CHECKBOX,':')) t on (h.id = t.column_value);
apex_string.split_numbers will convert your colon list into an actual "table" with the column column_value you can use in the join clause. listagg will do the actual concatenation and will work up to a couple thousand characters. chr(10) is an ordinary line break and will have your items be shown line by line, but any other seperator will do.
Last step is to set up P10_CHECKBOX in your Items to submit and P10_TEXT in your Items to return.
Now, whenever you click a checkbox, the textarea will be updated immediately.

How I can make Mandatory add at least one row in Interactive grid in apex oracle

I have two region one form and one interactive grid like a master detail(company and company contact person ) how i can make the interactive grid mandatory ,the user can't submit page ,he/she need add at least one row in interactive grid ,
I can do that or I need to change the interactive grid to collection and count the row in validation
This one is a little tricky because of the way processes and validations work with Interactive Grids (they are executed once per submitted row). To work around this, I'll use a page item and a validation that works with it.
The basic idea of this solution is based on the fact that a new row will not have a primary key value. Here are the steps to reproduce (my example was on page 14, update the following as needed).
Create an Interactive Grid (IG) region. The primary key column should be Query Only (which ensures it's null for new rows).
Create a Hidden page item named P14_NULL_FOUND. Set Type under Server-side Condition to Never so that it never renders on the page.
Create an After Submit (before Validations) process. This process will NOT be associated with the IG so it will only fire once. Set the PL/SQL Code attribute to:
:P14_NULL_FOUND := 'NO';
That will clear out the value of the page item prior to the next process.
Create another After Submit process that runs just after the previous one. Set Editable Region to the IG. Then set the PL/SQL Code to something like the following:
if :PK_COLUMN_IN_IG is null
then
:P14_NULL_FOUND := 'YES';
end if;
You'll need to replace ":PK_COLUMN_IN_IG" with the name of the primary key column in the IG, such as ":EMPNO". This process will be run once for each submitted row in the IG. If a null value is found for the primary key column, then that would mean the user added a new row and the value of P14_NULL_FOUND would be set to 'YES'.
Create a new validation. This validation will NOT be associated with the IG so it will only fire once. Set Type to PL/SQL Expression. Set PL/SQL Expression to:
:P14_NULL_FOUND != 'NO'
Then set Error Message to something relevant.
At this point, you should be able to run the page and verify that the processes and validation are working correctly.
There is an another solution;
Create a page item like PX_ROWCOUNT which will hold the data of the row count of your IG.
Assign a static ID to your IG region.
Write a JS function to count the rows of the grid then set it to the page item. Sample function;
function f_setRowCount(){
var grid = apex.region("staticIDOfYourIG").widget().interactiveGrid("getViews", "grid");
var model = grid.model;
var rowCount = 0;
model.forEach(function (record) {
rowCount ++;
});
$s("PX_ROWCOUNT",rowCount);
}
To submit your page and run this function, change your submit button's behavior to Defined by Dynamic Action. Execute your function when user clicks to that button then submit your page via DA.
Add validation to Processing section of the page and check your page item there; PLSQL Expression => :PX_ROWCOUNT > 0
The solution by Hamit works nicely, except of the case of deletion of a row.
My suggestion is to amend the above code by adding inside the loop an if statement to check whether the row is editable or no.
So the code will be
var grid = apex.region("staticIDOfYourIG").widget().interactiveGrid("getViews", "grid");
var model = grid.model;
var rowCount = 0;
model.forEach(function (record) {
if (model.allowEdit(record)) {
rowCount ++;
}
});
$s("PX_ROWCOUNT",rowCount);

How to prepopulate date field based on other date field?

I have 2 date fields in oracle apex, Date1 is mandatory needs to be input by user and Date2 needs to prepopulate as (Date1+2 years) then user clicks the save button to save the values in database.
Then, if user clicks Date2 and change to something else, it should take that value and save.
Eg:
1.User inputs Date1 - 02/07/2019
2.Date2 should automatically populate as - 02/07/2021 but should not be saved in database.
3.User clicks save button to save data.
4.User wants to change Date2 to - 05/10/2019
5.User clicks save to save data.
I tried to set value using dynamic action for step2, but step4 is not working whenever I click save button, it's recalculating back to Date1+2 years.
Please help.
Suppose you have P1_ID (primary key), P1_DATE1 and P1_DATE2 on your form.
Create a dynamic action to set value of P1_DATE2 on change of P1_DATE1. Use PL/SQL Expression as type and PL/SQL Expression
ADD_MONTHS(TO_DATE(:P1_DATE1,'DD/MM/YYYY'),24);
Set "Fire on initialization" to false so it won't recalculate P1_DATE2 when the screen loads for an existing record - that might be the cause of the behaviour you're seeing.
It makes sense that you only want the dynamic action to fire for a new record so you could add a server-side condition in your dynamic action of "ITEM IS NULL" for item P1_ID.

xml for accessing the repeater control row values in infopath form

I have the web service, which has method State() that returning the List. where i want to design the infopath form that having the repeating table. in repeating table one of column should have the drop down list.
I want to populate this List in the drop down list (states). Each selected instance in the dropdown must be unique means when i would select state A for row 1 then in other row there must be validation that should not select the state A again.
in short avoid the duplicate selection.
Include a section with a validation message under each dropdown. Select the section Properties > Display > Conditional formatting.
Set the condition as dropdown2_field is equal to dropdown1_field.
(Need to add similar multiple conditions for 3rd,4th successive dropdown boxes.)
and select Hide this control check box.
If the user selects the same state in dropdown2 the validation message is shown.