Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to filter dropdown result #628

Open
UcoxGanteng opened this issue Jul 10, 2024 · 2 comments
Open

[Question] How to filter dropdown result #628

UcoxGanteng opened this issue Jul 10, 2024 · 2 comments

Comments

@UcoxGanteng
Copy link

Description [describe your questions]

RIght now, the result of dropdown are all the column in table, so how to get with filter, such as only key value or wanted field.
Now: Sample
Table X
column 1 column 2
A 111
A 222
B 333
B 444

question: how to get only show in dropdown are A values....111, 222,

Example code [If you have any code info]

// Drop down Nermo
formList.AddField("Nermo", "sb_nrhdr", db.Varchar, form.SelectSingle).
	FieldOptionsFromTable("m_nermo", "nr_nrhdr", "nr_nrhdr").FieldNotAllowEdit().
	FieldInputWidth(3)

Others [screenshots or other info]

@eduartos
Copy link

you can provide WHERE-filter in FieldOptionsFromTable:

filterFn := func(sql *db.SQL) *db.SQL {
	return sql.Where("columnName", "=", "A")
}

formList.AddField("Nermo", "sb_nrhdr", db.Varchar, form.SelectSingle).
	FieldOptionsFromTable("m_nermo", "nr_nrhdr", "nr_nrhdr", filterFn).FieldNotAllowEdit().
	FieldInputWidth(3)

@UcoxGanteng
Copy link
Author

UcoxGanteng commented Jul 14, 2024

Sorry, its not working, got erros

what I want to know how to get the result from first select and use the result as a compare field in second select:

formList.AddField("Nermo", "sb_nrhdr", db.Varchar, form.SelectSingle).FieldNotAllowEdit().
	FieldInputWidth(3).
	FieldOptionsFromTable("m_nermo", "nr_nrhdr", "nr_nrhdr")

formList.AddField("MstNumber", "sb_coano", db.Varchar, form.SelectSingle).
	FieldOptionsFromTable("mmaster", "ac_coano", "ac_coano",
		func(sql *db.SQL) *db.SQL {
			return sql.Table("mmaster").Where("ac_nrhdr", "=", "sb_nrhdr")

look at "sb_nrhdr" , first select as a result, and I want to use this result in second select, but its not working
Anyone can help ?
thank u

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants