简体   繁体   中英

show result List as per count

在此处输入图像描述

Like here, I want the number of times it has in registration array, I want to show it in a single row. Currently its like below, But I want it like if there's 2 result then I want it 2 time in a single row.

在此处输入图像描述

So here if you check the prototype(of item ), You can see 2 count, so i want to show 2 results, along sides.

const title = responseData.map(item => {

                    return { label: `${item.title} (${item.registration[0].registration_type.code}) (${item.registration.length.toString()})`, value: item._id };

            });

I am assuming the data you want in each row is all stored inside each element in the item.registration array.

const title = responseData.map(item => {
    // map all the values inside the registration on to an array of labels
    const labels = item.registration.map(registration => {
        return `${item.title} (${registration.registration_type.code})`; 
    })

    // Join the labels created above with a comma separating them
    return { label: labels.join(', '), value: item._id };
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM