Skip to content

Async loading of fields to select field based on the keyword that typing in #1269

@shijiezhou1

Description

@shijiezhou1

The react-awesome-query-builder not able to provide the option to async load the selecting field.

if i have more than 5000 fields, the program will stuck on hanging on the screen.

see the code below

const fields = {};
    for (let i = 0; i < 1000; i++) {
        fields[`qty_${i}`] = {
            label: `Qty ${i}`,
            type: 'number',
            tooltip: "Qty",
            fieldSettings: {
                min: 0,
                fetchSelectedValuesOnInit: true
            },
            valueSources: ['value'],
            preferWidgets: ['number'],

        };
        fields[`price_${i}`] = {
            label: `Price ${i}`,
            type: 'number',
            valueSources: ['value'],
            fieldSettings: {
                min: 10,
                max: 100,
            },
            preferWidgets: ['slider', 'rangeslider'],
        };
        fields[`name_${i}`] = {            label: `Name ${i}`,
            type: 'text',
        };
        fields[`color_${i}`] = {
            label: `Color ${i}`,
            type: 'select',
            valueSources: ['value'],
            fieldSettings: {
                listValues: [
                    { value: 'yellow', title: 'Yellow' },
                    { value: 'green', title: 'Green' },
                    { value: 'orange', title: 'Orange' }
                ],
            }
        };
        fields[`is_promotion_${i}`] = {
            label: `Promo? ${i}`,
            type: 'boolean',
            operators: ['equal'],
            valueSources: ['value'],
        };
    }

    const emptyInitValue = { id: Utils.uuid(), type: "group" }
    const [initConfig, setInitConfig] = useState({ ...MuiConfig, fields })

    const [state, setState] = useState({
        tree: Utils.checkTree(Utils.loadTree(emptyInitValue), initConfig),
        config: initConfig
    })


 <Query
                {...state.config}
                value={state.tree}
            />

how can i make it work? so i can load 5000 fields async? or can we use react-window or virtual scrolling package? any solution?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    onlydust-waveContribute to awesome OSS repos during OnlyDust's open source week

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions