jQWidgets
  • Documentation
  • License and Pricing
  • Services
  • Community
    • Forums
    • Blogs
    • Follow Us
    • Client Login
  • About
    • About Us
    • Contact Us
    • FAQ
  • Demo
  • Download

React UI Components

  • Javascript/jQuery
  • Angular
  • Vue
  • React
  • Custom Elements
  • ASP .NET MVC
  • Showcase Demos
  • Responsive Design
  • Theme Builder
Show Demo List

React UI Components

  • jqxGrid
  • jqxTabs
  • jqxTextArea
  • jqxWindow
  • jqxKnob
  • jqxResponsivePanel
  • jqxChart
  • jqxMenu
  • jqxInput
  • jqxDocking
  • jqxGauge
  • jqxNavBar
  • jqxPivotGrid
  • jqxTree
  • jqxPasswordInput
  • jqxNotification
  • jqxBarGauge
  • jqxSortable
  • jqxScheduler
  • jqxNavigationBar
  • jqxMaskedInput
  • jqxPopOver
  • jqxExpander
  • jqxLoader
  • jqxTreeGrid
  • jqxListMenu
  • jqxComplexInput
  • jqxTooltip
  • jqxRating
  • jqxDraw
  • jqxDataTable
  • jqxToolBar
  • jqxFormattedInput
  • jqxColorPicker
  • jqxRangeSelector
  • jqxDragDrop
  • jqxTreeMap
  • jqxComboBox
  • jqxNumberInput
  • jqxScrollView
  • jqxSlider
  • jqxPanel
  • jqxEditor
  • jqxDropDownList
  • jqxDateTimeInput
  • jqxProgressBar
  • jqxScrollBar
  • jqxValidator
  • jqxRibbon
  • jqxListBox
  • jqxCalendar
  • jqxFileUpload
  • jqxSplitter
  • jqxValidator
  • jqxLayout
  • jqxButtons
  • jqxKanban
  • jqxBulletChart
  • jqxDockingLayout

jqxDataTable

  • Default Functionality
  • Data Binding
    • Local Data
    • Remote Data
    • XML Data
    • JSON Data
    • CSV Data
    • TSV Data
  • Rows
    • Row Template
    • Row Details
    • Row Selection & Hover
  • Columns
    • Columns Hierarchy
    • Column Formatting
    • Column Alignment
    • Column Resize
    • Column Reorder
    • Show or Hide Column
    • Pinned(Frozen) Column
    • Column Template
    • Header Template
  • Editing
    • Inline Row
    • Dialog
    • Lock Row
    • Cell Edit
    • Custom Editors
    • Validation
  • Sorting
    • Sorting
    • Server Sorting
    • Sorting API
  • Filtering
    • Filtering
    • Search Field
    • Advanced Filtering
    • Server Filtering
    • Filtering API
  • Paging
    • Paging
    • Server Paging
    • Paging API
  • Master Details
    • Nested Tables
    • Separate Tables
  • Aggregates
    • Aggregates
    • Aggregates Template
  • Grouping
    • Grouping
    • Grouping & Server Paging
  • Data Export
  • Data Printing
  • Localization
  • Conditional Formatting
  • Fluid Size
  • Keyboard Navigation
  • Right to Left Layout
Theme:
  • Demo
  • App.htm
  • App.js
ReactJS DataTable demo. The sample illustrates how to add custom CSS styles to DataTable cells under specific conditions.
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title id='Description'>
        ReactJS DataTable demo. The sample illustrates how to add custom CSS styles to DataTable cells under specific conditions.
    </title>
    <link rel="stylesheet" href="../jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" src="../jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="../jqwidgets/jqxdata.js"></script>
    <script type="text/javascript" src="../jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="../jqwidgets/jqxscrollbar.js"></script>
    <script type="text/javascript" src="../jqwidgets/jqxdatatable.js"></script>
    <script type="text/javascript" src="../scripts/demos.js"></script>

    <style>
        .max {
            color: black\9;
            background-color: #63be7b\9;
        }

        .avg {
            color: black\9;
            background-color: #f8e984\9;
        }

        .minavg {
            color: black\9;
            background-color: #f9806f\9;
        }

        .min {
            color: black\9;
            background-color: #f8696b\9;
        }

        .max:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected), .jqx-widget .max:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected) {
            color: black;
            background-color: #63be7b;
        }

        .avg:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected), .jqx-widget .avg:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected) {
            color: black;
            background-color: #f8e984;
        }

        .minavg:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected), .jqx-widget .minavg:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected) {
            color: black;
            background-color: #f9806f;
        }

        .min:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected), .jqx-widget .min:not(.jqx-grid-cell-hover):not(.jqx-grid-cell-selected) {
            color: black;
            background-color: #f8696b;
        }
    </style>

</head>
<body>
    <div class="example-description" style="margin-bottom:3em">
        ReactJS DataTable demo. The sample illustrates how to add custom CSS styles to DataTable cells under specific conditions.
    </div>
    <div id="app"></div>
    <script src="../build/datatable_conditionalformatting.bundle.js"></script>
</body>
</html>

import React from 'react';import ReactDOM from 'react-dom';import JqxDataTable from '../../../jqwidgets-react/react_jqxdatatable.js';class App extends React.Component {
    render() {
        let source =
            {
                dataType: 'xml',
                dataFields: [
                    { name: 'ProductName', type: 'string' },
                    { name: 'QuantityPerUnit', type: 'int' },
                    { name: 'UnitPrice', type: 'float' },
                    { name: 'UnitsInStock', type: 'float' },
                    { name: 'Discontinued', type: 'bool' }
                ],
                root: 'Products',
                record: 'Product',
                id: 'ProductID',
                url: '../sampledata/products.xml'
            };

        let dataAdapter = new $.jqx.dataAdapter(source);

        let cellClass = (row, dataField, cellText, rowData) => {
            let cellValue = rowData[dataField];
            switch (dataField) {
                case 'QuantityPerUnit':
                    if (cellValue < 11) {
                        return 'min';
                    }
                    if (cellValue < 14) {
                        return 'minavg';
                    }
                    if (cellValue < 50) {
                        return 'avg';
                    }
                    return 'max';
                case 'UnitPrice':
                    if (cellValue < 20) {
                        return 'min';
                    }
                    if (cellValue < 30) {
                        return 'minavg';
                    }
                    if (cellValue < 50) {
                        return 'avg';
                    }
                    return 'max';
                case 'UnitsInStock':
                    if (cellValue < 20) {
                        return 'min';
                    }
                    if (cellValue < 30) {
                        return 'minavg';
                    }
                    if (cellValue < 50) {
                        return 'avg';
                    }
                    return 'max';
            }
        }

        let columns =
            [
                { text: 'Product Name', dataField: 'ProductName', width: 200 },
                { text: 'Quantity per Unit', dataField: 'QuantityPerUnit', cellClassName: cellClass, cellsAlign: 'right', align: 'right', width: 200 },
                { text: 'Unit Price', dataField: 'UnitPrice', align: 'right', cellClassName: cellClass, cellsAlign: 'right', cellsformat: 'c2', width: 200 },
                { text: 'Units In Stock', dataField: 'UnitsInStock', cellsAlign: 'right', width: 250, align: 'right', cellClassName: cellClass }
            ];

        return (
            <JqxDataTable
                width={850} source={dataAdapter} altRows={true}
                pageable={true} sortable={true} enableHover={false}
                columns={columns} selectionMode={'none'}
            />
        )
    }
}

ReactDOM.render(<App />, document.getElementById('app'));
jQWidgets
  • Facebook
  • Youtube
  • Google +
  • Demo
  • Download
  • Documentation
  • License and Pricing
  • Services
  • Forums
  • About
  • Terms of Use
  • Privacy Policy
  • Contact Us

jQWidgets © 2011-2019. All Rights Reserved.