我使用以下代码使用数据库中的列表值动态填充react-awesome-query-builder。当我运行此代码并激活下拉菜单时,它说没有数据。
我查看了 JSON 格式,它看起来与 Github 上的示例中的预制配置文件相同(https://github.com/ukrbublik/react-awesome-query-builder)。有什么办法可以动态填充列表吗?如果是这样,有什么明显的问题吗?
const loadMetricConfigFields = async () => {
let fields = {};
const result = await FetchData(url);
// Set up the category fields that will hold the metrics
result.forEach(element => {
fields[`${element.categoryName}`] = {
label: element.categoryName,
subfields: {},
tooltip: 'tooltip',
type: '!struct'
};
});
for (let count = 0; count < result.length; count++) {
// Set up the subfields first
fields[`${result[count].categoryName}`]['subfields'][count] = {
label: result[count].name,
type: result[count].uiComponentName.toLowerCase(),
valueSources: ['value', 'field'],
operators: [],
fieldSettings: …Run Code Online (Sandbox Code Playgroud)