Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
362 views
in Technique[技术] by (71.8m points)

reactjs - Highlight certain rows matched with data array in MUI-Datatables

I am using MUI-Datatables to display retrieved data. my requirement is to highlight the row according to the matched data. I was able to do this using 'setrowProps' which is only working if I compare it with the text like 'operations'. I have an array to be highlighted. Don't know how to highlight those rows using arrays. please help, here is my code

let content = [
    {id:20, name:'Jack Daniel', title:'accounting'},
    {id:21, name:'Sophie McDonald', title:'operations'},
    {id:22, name:'Jason Thomas', title:'hospitality'},
    {id:23, name:'Chris Williams', title:'kitchen'}
]

let highlight = [
                 0:"operations" 
                 1: "kitchen"
                ]

const containmentOptions = {
    filterType: 'multiselect',
    selectableRows: 'none',
    confirmFilters: true, 
    setRowProps: (row, dataIndex, rowIndex) => {
        return { 
            className: clsx({     
                highlight.map(item=>{  
                    [this.props.classes.new]: row[2] === item[0];
                })
            }),
        }        
     }
}

//It is giving me an error at highlight "unexpected token"

[this.props.classes.new]: row[2] === 'operations' // the row gets highighted but not with array
question from:https://stackoverflow.com/questions/65944397/highlight-certain-rows-matched-with-data-array-in-mui-datatables

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...