Dropdown (select) widget with asyncFetch cant select and keep any value from dropdown #515
Answered
by
silviu-ion
silviu-ion
asked this question in
Q&A
Replies: 3 comments 2 replies
-
Can you please provide more info so I can reproduce your problem? |
Beta Was this translation helpful? Give feedback.
1 reply
-
I solved the problem, it's about the value of object option for selector ,
there need to be string value and i have an int value :)
thanks
…On Mon, Oct 18, 2021 at 12:36 AM Denis Oblogin ***@***.***> wrote:
Can you please provide more info so I can reproduce your problem?
Eg. can you dump results you get in productsValues?
Video recording would be helpful, as well as dump of XHRs you get during
issue reproducing.
If you can give access to your API server for demo purposes, it would be
great
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#515 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ATQCEGWS4BVBRVL4HEWLAQDUHM6VTANCNFSM5FW5WG4Q>
.
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ukrbublik
-
I also have an problem with
but in interface dropdown with items - always empty
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When I select any value from dropdown with asyncFetch and click outside of the dropdown the value set to empty :(
Can someone tell me how can i solve that?
config i used.
`import _ from "lodash";
import MaterialConfig from 'react-awesome-query-builder/lib/config/material';
import authHeader from "../../../service-api/auth-header";
import axios from "../../../utils/axios";
const InitialConfig = MaterialConfig;
const config = {
...InitialConfig,
settings: {
...InitialConfig.settings,
showLabels: true,
excludeOperators: {
text: ['proximity'],
},
showNot: false,
maxNesting: 2,
},
fields: {
orders: {
type: '!struct',
label: 'Orders',
subfields: {
total: {
type: 'number',
preferWidgets: ["number"],
label: 'Total',
fieldSettings: {
validateValue: (val, fieldSettings) => {
return (val < 0);
},
},
},
subtotal_total: {
type: 'number',
preferWidgets: ["number"],
label: 'Sub total',
},
discount: {
type: 'number',
preferWidgets: ["number"],
label: 'Discount',
},
taxes: {
type: 'number',
preferWidgets: ["number"],
label: 'Taxes',
},
shipping: {
type: 'number',
preferWidgets: ["number"],
label: 'Shipping',
},
payment_method: {
type: 'text',
label: 'Payment Method',
excludeOperators: ["proximity"],
},
currency: {
type: 'text',
label: 'Currency',
excludeOperators: ["proximity"],
},
user_email: {
type: 'text',
label: 'User Email',
excludeOperators: ["proximity"],
}
}
},
customers: {
type: '!struct',
label: 'Customers',
subfields: {
first_name: {
type: 'text',
label: 'First Name',
excludeOperators: ["proximity"],
},
last_name: {
type: 'text',
label: 'Last Name',
excludeOperators: ["proximity"],
},
email: {
type: 'text',
label: 'Email',
excludeOperators: ["proximity"],
},
country: {
type: 'text',
label: 'Country',
excludeOperators: ["proximity"],
},
city: {
type: 'text',
label: 'City',
excludeOperators: ["proximity"],
},
state: {
type: 'text',
label: 'State',
excludeOperators: ["proximity"],
},
postcode: {
type: 'text',
label: 'Postcode',
excludeOperators: ["proximity"],
},
date_registered: {
type: 'datetime',
label: 'Date Registered',
},
date_last_active: {
type: 'datetime',
label: 'Date Last Active',
},
gender: {
type: 'text',
label: 'Gender',
excludeOperators: ["proximity"],
},
geolocation: {
type: 'text',
label: 'Geolocation',
excludeOperators: ["proximity"],
},
birthday: {
type: 'date',
label: 'Birthday',
}
}
},
products: {
type: '!struct',
label: 'Products',
subfields: {
title: {
type: 'select',
label: 'Name',
fieldSettings: {
asyncFetch: async (search, offset) => {
const toSearch = _.isEmpty(search) ? 'null' : search;
const prodApi = (await axios.get(
http://localhost:8002/api/products/1/${toSearch}?offset=${offset}
, { headers: authHeader() }));const productsValues = prodApi.data.data.map(
product => ({
title: product.title,
value: product.id
})
)
}
};
export default config;
`
Beta Was this translation helpful? Give feedback.
All reactions