Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
9
Erster Beitrag:
vor 1 Jahr, 1 Monat
Letzter Beitrag:
vor 1 Jahr, 1 Monat
Beteiligte Autoren:
Mark Crichton, Al, Fabrice Harari

Combo control - view many but select few

Startbeitrag von Mark Crichton am 27.06.2016 22:06

Hi Everyone.

I'm looking for the best practice to resolve the following. I may be missing the obvious….

Data file has 1000+ products of which only +-20 are active at any one time.

In a table of e.g.: product records there is a productid linked to a combo control that returns the product name. All possible products must be in the content query to display all possible ids.

However. If the user is to select a product for a new record, they must only be able to choose a product that is currently "Active". Ie: select from a shorter list of options.

Currently I use two columns, one to display and another as the chooser. The chooser is only made visible in edit mode. I would ideally like the on column to handle the complete scenario. Ie: the dropdown has a different list to whats viewed.

thanks Mark

Antworten:

Hello Mark

Do you fill the combo before the table loads ?
If so just restrict the data before you load the combo with either a file filter or a query as the source.

Regards
Al

von Al - am 27.06.2016 23:33
Hi Al

Thanks for response.
Not sure I understand you.
Combo has Qry_AllProducts set up in the column description.content.
I need qry_ActiveProducts when selecting the product.
If I use a filter on the qry_Allproducts then inActive product descriptions will be blank.

Regards Mark

von Mark Crichton - am 28.06.2016 00:01
Hello Mark

Maybe it only works for memory tables but you can prefill the combobox before you load the table
"ExpenseType" is a combobox in the memory table calle "TABLE"
This code fills it before I load the records into the table.
The combobox in the table is set as "Return the Value specified by Glink"

//Setup the expense types
gLinkActivate(TABLE.ExpenseType)
ListDeleteAll(TABLE.ExpenseType)
HReadFirst(ExpType,EXCLEUNIK)
WHILE NOT HOut(ExpType)
ListAdd(TABLE.ExpenseType,EX.Description+gLink(EX.EXCLEUNIK))
HReadNext(ExpType,EXCLEUNIK)
END

//Fill the memory table

As you can see, I can put whatever I like into the combobox and it displays the items that matches the underlying data from the table.

Regards
Al

von Al - am 28.06.2016 00:41
Hi Al

I've had a play with gLink ( last week and again now) and looked at all the documentation I can find. It makes no sense to me, so struggling. Wish I could find a good explanation of how link works.

Can you help me a bit more, as to how I code this. Steps I think I need to do

1. Make table a memory table. - done that
2. Check the "Return Value by gLink" in Details tab - done that
3. Have the content of the col_prdname in the table description = try_allproducts to get the rows of the table to lookup product name correctly
4. Col_prdname is linked to stock.prdid
3. Load data from qry_ActiveProduct into Table_StockReceipt.col_prdname which is the combo box control when I init the table
HExecuteQuery(QRY_ActiveProducts,hQueryDefault)
gLinkActivate(COL_PrdName)
ListDeleteAll(COL_PrdName)
HReadFirst(QRY_ActiveProducts)
WHILE NOT HOut(QRY_ActiveProducts)
ListAdd(COL_PrdName,QRY_ActiveProducts.prdname+gLink(QRY_ActiveProducts.prdid))
HReadNext(QRY_ActiveProducts)
END

4. Execute my qry_AllSales and TableDisplay from Filter button

Results of this.

test 1 - table shows blank instead of product name and combo box has all lines
test 2 - set glink code to run after setting filter, the combo box shows only active products, but retuns wrong name, and the column still returns a blank

regards Mark

von Mark Crichton - am 28.06.2016 02:46
HI Al

Solved the blanks problem. ...wrong link field
Not getting the active only list when I load the form.
Can load it if I run the above code after my filter, but get no link value returned.
col_prdname returns 0 after selecting the rename from the combo box

Thanks Mark

von Mark Crichton - am 28.06.2016 03:34
Hello Mark

The combobox can return the actual string displayed in the box, its numeric row count or the invisible glink() value attached to the current row.
The value your query puts into the col_prdname column should find a match in the glink value of QRY_ActiveProducts.prdid in the combo box.
The glink value from the combo box would be val(col_prdname)..storedvalue

Regards
Al

von Al - am 28.06.2016 12:04
Hi Mark,

just in case you didn't think of that solution already... It should be possible to set the height of each non active line in the combo to ZERO when in edit mode with a loop.

It should also be possible to :
- load the whole file in a query and keep it there during the life span of your table
- Load the combo content by code, either with ALL lines or only ACTIVE lines when needed
As all would be done in memory, it should be very fast...

Best regards

von Fabrice Harari - am 28.06.2016 12:44
Thanks AL and Fabrice.

Lots to try out. I'll get back soon.

von Mark Crichton - am 29.06.2016 00:41
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.