Hi Team I will share samle screen existing and new.
I need exactly out put.

Hi Team I will share samle screen existing and new.
I need exactly out put.

Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sangeetha SRank #212 · 11.4K reputationPosted Dec 2, 2024, 1:21 AM EST
Hi,
Grouped Data in a DataTable general example
import React from 'react'; const DataTable = ({ groupedData }) => { return ( CategoryItem {Object.entries(groupedData).map(([category, items]) => ( {category}{items[0].item} {items.slice(1).map((item) => ( {item.item} ))} ))} ); }; const App = () => { const data = [ { id: 1, category: 'Fruits', item: 'Apple' }, { id: 2, category: 'Fruits', item: 'Banana' }, { id: 3, category: 'Vegetables', item: 'Carrot' }, { id: 4, category: 'Fruits', item: 'Orange' }, { id: 5, category: 'Vegetables', item: 'Lettuce' }, ]; const groupedData = groupData(data); return ( Grouped Data Table ); }; export default App;amar Praveen31 reputationPosted Dec 11, 2024, 11:32 PM EST
Need full example it's only single value .Can you please share screen shot of output.
Sangeetha SRank #212 · 11.4K reputationPosted Dec 12, 2024, 12:25 AM EST
Hi,
import React from 'react'; const groupData = (data) => { return data.reduce((acc, item) => { if (!acc[item.category]) { acc[item.category] = []; } acc[item.category].push(item); return acc; }, {}); }; const DataTable = ({ groupedData }) => { return ( CategoryItem {Object.entries(groupedData).map(([category, items]) => ( {category}{items[0].item} {items.slice(1).map((item) => ( {item.item} ))} ))} ); }; const App = () => { const data = [ { id: 1, category: 'Fruits', item: 'Apple' }, { id: 2, category: 'Fruits', item: 'Banana' }, { id: 3, category: 'Vegetables', item: 'Carrot' }, { id: 4, category: 'Fruits', item: 'Orange' }, { id: 5, category: 'Vegetables', item: 'Lettuce' }, ]; const groupedData = groupData(data); return ( Grouped Data Table ); }; export default App;run this code, and table that looks like this: