how to refresh combobox items in vb .net - refresh

how to refresh combobox items in vb .net

If you're talking about a comboBox on a WinForm that's been assigned to a list of objects using the datasource property, I found that you must nullify the datasource setting and re-assign it every time your list changes.
i.e.
attendanceDataFiles.DataSource = Nothing
attendanceDataFiles.DataSource = myFileList.files
attendanceDataFiles.DisplayMember = "displayName"
attendanceDataFiles.ValueMember = "fileName"

This is another way to refresh combo box items if your combo box's content is from MySql Database. You can customize your results in the query.
comboboxname.Items.clear() 'empty combo box content first
query = "select code, description from tbl_mode_of_payment where cat = 'LICENSE'" 'mysql query that retrieves payment code and its description based on category
cmd = New MySqlCommand(query, con)
reader = cmd.ExecuteReader()
While reader.Read
comboboxname.Items.Add(reader.GetString("code") + " - " + reader.GetString("description")) 'add results into the combo box
End While
con.Close()

Textbox1.Item.Clear()
then
call.item_tb()

Related

Dialog Return Item value is not returned

I am using Oracle APEX 21.1. I've created a report with a form. The query of the report is...
SELECT DECODE(I.visit_type_id, 1, 'فحص', 'متابعة') process_patient,
I.VISIT_ID,
I.PATIENT_ID,
I.VISIT_DATE,
I.VISIT_TYPE_ID,
I.REFERRED_FROM_ID,
I.EXAMINATION_FOLLOWUP_ID,
P.NAME PATIENT_NAME,
P.AGE,
C.NAME CITY
FROM
(SELECT V.ID VISIT_ID,
V.PATIENT_ID,
V.VISIT_DATE,
V.VISIT_TYPE_ID,
V.REFERRED_FROM_ID,
E.ID EXAMINATION_FOLLOWUP_ID
FROM PATIENT_VISIT V
LEFT JOIN EXAMINATION E ON E.VISIT_ID = V.ID
WHERE VISIT_TYPE_ID = 1
UNION ALL SELECT V.ID VISIT_ID,
V.PATIENT_ID,
V.VISIT_DATE,
V.VISIT_TYPE_ID,
NULL REFERRED_FROM_ID,
F.ID FOLLOW_UP_ID
FROM PATIENT_VISIT V
LEFT JOIN FOLLOW_UP F ON F.VISIT_ID = V.ID
WHERE VISIT_TYPE_ID = 2 ) I
JOIN PATIENT P ON P.ID = I.PATIENT_ID
LEFT JOIN CITY C ON C.ID = P.CITY_ID;
As you can see, there are 2 modal pages that should open based on visit_type_id which is the parameter to the DECODE function. This is the part where the problem resides. In modal page 2, I created an item and a process to set the item's value to the REQUEST VALUE :P2_REQUEST := :REQUEST. In page 14(the report page), I've created an item P14_REQUEST and a Dialog Closed dynamic action with the When section's Selection Type set to javaScript expression and the expression = window. Then added a true action (Set Value) with type = dialog return item. The item is P2_REQUEST and the affected element is P14_REQUEST. The value of the request is returned successfully to P14_REQUEST. The problem is about the second page(5). When I do the same steps aforementioned, the value of the request is not returned at all. Is there a bug or something prevent working with multiple modal pages?
I have created a simulation on apex.oracle.com - a report(7) that calls 2 modal pages(9 and 10), when you update any value in any modal page and submits the page, the request value should be returned to P7_REQUEST. Unfortunately, that does not happen now using either pages. Maybe I am missing something.
ws= ESLAM_WS
un= forhelp
pwd= Forhelppwd$
app= help
pages= 7, 9 and 10
Unfortunately, I forgot to set Items to return attribute of the Close Dialog process.

Application item not working for Interactive grid

In my application, i have application item that stores employee id.
I have a form where emp_id=application item id and an interactive grid which also has application item in where clause.
In form, the application item value is available and shows as emp_id.
But in interactive grid it doesn't .
Form P1_emp_id =:APP_ID -> Displays emp_id = 1
IG : emp_id = :APP_ID -> emp_id is null.
It doesn't take the application item value although it is there in the session.
Did you try to give 'submit' or 'return item' values? Maybe you should add the item there and it will take the value. Or try 'fire on initialization: yes' and put the page on 'after refresh'. If none of them works then please provide us more detailt to solve this problem, thanks.

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 insert programmatically a value in a new row of a QtableView

I'm using a QtableView to display and edit data from a QsqlTableModel.
Everything's fine : data from a postgreSQL table is displayed, and user can edit it and save modifications.
I want to add a row when uses click on a button. I use the insertRecord method from my QslTableModel.
The row is correctly added in the QTableView.
My problem is :
I want to insert a value from a query in the first cell of this new row. (to automatically populate an unique identifier).
This is my code :
def ajoutlgn(self):
query_idNewLine = QtSql.QSqlQuery(self.db)
if query_idNewLine.exec_('SELECT sp_idsuivi+1 FROM bdsuivis.t_suivprev_tablo ORDER BY sp_idsuivi DESC LIMIT 1'):
while query_idNewLine.next():
identifiant = query_idNewLine.value(0)
#print identifiant
record = QtSql.QSqlRecord()
record.setValue(1,identifiant)
self.model.insertRecord(self.model.rowCount(), record)
The value is not inserted in the new row (but if I enter a value by hand, it works perfectly).
Nevertheless, the query is OK (as I can see with the « print identifiant » line, which returns the expected integer).
Do you see what I'm doing wrong ?
Are there other methods to insert programmatically a value in a QTableView cell?
Or do I have to use a QitemDelegate ?
Thanks for advance.
Finally I found the solution :
This line creates a record, but not a record for my QsqlTableModel
record = QtSql.QSqlRecord()
I replaced it with this one, and it works perfectly :
record = self.model.record()

How to get the count of buttons present on a webpage in selenium webdriver

For eg: There is a list of flights displayed on a webpage. How to get the total count of "Select" buttons displayed on that webpage
When using the Java client bindings for example you can do something like that:
int count = driver.findElements(By.xpath("//a[.='Select']")).size();
snapshot of the problem would be really helpful. Yet trying to solve assuming you have list have fights displayed and trying to find count of select button. Probably 10 flights and 10 buttons
You can use Select class in selenium.
Select oSelect = new Select(driver.findElement(By.name("Select")));
List<WebElement> elem = oSelect.getOptions();
int iSize = elem.size();
System.out.println("Count of select button " +iSize);