I came across a very nice package called react-datasheet-grid. I want to color a specific cell depending on it's value. When I build the table (data-sheet) I do it with an array of columns as the doc says. When I want to style it there are examples only for styles the whole table. I want to style a specific cell but I don't know how to reach it.
Style cell in react-datasheet-grid
955 Views Asked by Itai Ben-Avraham At
2
There are 2 best solutions below
0
Hussam Khatib
On
You can use cellClassName prop to achieve it.
https://react-datasheet-grid.netlify.app/docs/api-reference/columns/#cellclassname
<DataSheetGrid
value={data}
onChange={setData}
columns={columns}
cellClassName={({ rowData, rowIndex, columnId }) => {
if(rowData.firstName === 'Alice'){
return 'bg-red' // a class defined in our stylesheet
}
}}
/>
Related Questions in CSS
- CSS Class is not applying to element (border width,color,and style attributes)
- How do I find the fonts that are not loading in a CORS situation ( MoovWeb )?
- Positioning child at bottom of parent with scroll
- Play multiple audio files in a slider
- How to set text over image?
- Website zoomed out on Android default browser
- Writing/Overwriting to specific XML file from ASP.NET code behind
- My navbar is not expanding after collapse
- when a checkbox is checked how to display a different hidden element using javascript
- Gaps Vertically Using Dividers
- CSS: Preventing a property to affect on element until the end of transition
- Polygon Button with pure CSS
- transform-origin doesnt apply in safari
- show/hide multiple div tags at once and change the size of the remaining div tag
- Mask the image/maps/div (circle) using css and jquery
Related Questions in REACTJS
- What is `_dereq_()` inside React?
- React TypeError: React.renderComponent is not a function
- React - saving a component in the ref callback
- React Rails component: manually triggering a re-render
- React, ES6 - getInitialState was defined on a plain JavaScript class
- How to get multiple selected options value in React JS?
- React.render replace container instead of inserting into
- reactjs datagrid use html
- props is not initialized in react component
- How to display xml data using Reactjs
- hooking up the data model in ReactJS - syntax
- ReactJS: How to use an immutable empty array or object
- How to use Sinon.js FakeXMLHttpRequest with superagent?
- React select onChange is not working
- ReactJS - Tutorial Comment System > Threaded commenting
Related Questions in STYLES
- WPF - How to highlight a combobox border when focused
- Wpf No Highlight on ListBoxItem for Touch Devices
- Doing something on the value only if key exists in dictionary
- "Use Theme.AppCompat theme with this activity" Exception
- Multiple Node Styles
- Proper use of parentheses in if with and/or statements PHP
- How to remove style for selected item in ListBox WPF
- Scala "Sentence-Like" Function Definition
- curved style for image
- WPF custom button
- WPF style info from external text file
- WPF add new Slider style cause XamlParseException
- How to remove button border style?
- WPF: why my slider not show the minimum value on my label
- Choose Style depending on property
Related Questions in DATASHEET
- MS Access programmatically edit a datasheet cell value
- Set datasheet column header text (without using labels in the underlying form)
- Can access display multiline captions in Access 365 form datasheet view?
- Is there a way to employ the tab stop function on certain fields within my sub-form in datasheet view within the main form
- What does the [Bit 31:16] format mean, for example, in datasheet's
- How does this hardware increment register addresses for 32-bit values only by one via communication bus?
- Excel sorting a lot of data
- MS ACCESS - How to filter a splitform's datasheet by a multiple combobox values
- Style cell in react-datasheet-grid
- MS Access Datasheet view
- MS Access 2016. Synchronize two combo boxes on a form datasheet
- MSAccess: Call a summation from a subform (in datasheet view) to be displayed in a textbox on the master form?
- Copy from datasheet to ListBox
- Detecting selection change in datasheet form in Access
- How can I import data into read-only datasheet fields?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You can assign classNames within the cell object. Please see the [hopefully?] complete example below:
In this example, you would need to add the declared class to your CSS styling sheet. Here is my source in case you have follow-up questions - https://github.com/romanstan1/react-datasheet-header.
Note that if you plan to boilerplate the example, you will need to pass
tableContentin via props.