Hover Styles

By default, grid cells have solid backgrounds. This can get in the way of styling rows using pseudo selectors such as :hover. If you want to give a hover style to cells, things are simple. Just add some CSS based on the '.wj-cell' class and ':hover' pseudo-selector. If you want to give a hover style to entire rows, apply the hover pseudo-style to the '.wj-row' element instead, and extend it to the row's non-selected child cells:

import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; import * as wjGrid from '@grapecity/wijmo.grid'; // document.readyState === 'complete' ? init() : window.onload = init; // function init() { // // generate some random data var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), data = []; for (var i = 0; i < countries.length; i++) { data.push({ id: i, country: countries[i], downloads: Math.round(Math.random() * 20000), sales: Math.random() * 10000, expenses: Math.random() * 5000 }); } // // hover on cells var hoverCell = new wjGrid.FlexGrid('#hoverCell', { itemsSource: data }); // // hover on rows var hoverRow = new wjGrid.FlexGrid('#hoverRow', { itemsSource: data }); } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexGrid Hover Styles</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div class="container-fluid"> <h2>Hover on Cells</h2> <div id="hoverCell"></div> <h2>Hover on Rows</h2> <div id="hoverRow"></div> </div> </body> </html> .wj-flexgrid { height: 150px; margin: 10px 0; } /* css for hovering on non-header cells */ #hoverCell .wj-cells .wj-cell:not(.wj-state-selected):not(.wj-state-multi-selected):hover { background-color:rgb(200,255,200); transition: all 0.5s; } /* css for hovering on non-header rows */ #hoverRow .wj-cells .wj-row:hover .wj-cell:not(.wj-state-selected):not(.wj-state-multi-selected) { transition: all 0.5s; background: rgb(200,255,200); } import 'bootstrap.css'; import '@grapecity/wijmo.styles/wijmo.css'; import './styles.css'; // import { Component, Inject, enableProdMode, NgModule } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { BrowserModule } from '@angular/platform-browser'; import { WjGridModule } from '@grapecity/wijmo.angular2.grid'; import { DataService } from './app.data'; // @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { data: any; // DataSvc will be passed by derived classes constructor(@Inject(DataService) private dataService: DataService) { this.data = dataService.getData(); } } //\\ @NgModule({ imports: [WjGridModule, BrowserModule], declarations: [AppComponent], providers: [DataService], bootstrap: [AppComponent] }) export class AppModule { } // enableProdMode(); // Bootstrap application with hash style navigation and global services. platformBrowserDynamic().bootstrapModule(AppModule); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexGrid Hover Styles</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Polyfills --> <script src="node_modules/core-js/client/shim.min.js"></script> <script src="node_modules/zone.js/dist/zone.min.js"></script> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.js"></script> <script src="systemjs.config.js"></script> <script> // workaround to load 'rxjs/operators' from the rxjs bundle System.import('rxjs').then(function (m) { System.set(SystemJS.resolveSync('rxjs/operators'), System.newModule(m.operators)); System.import('./src/app.component'); }); </script> </head> <body> <app-component></app-component> </body> </html> <div class="container-fluid"> <h2>Hover on Cells</h2> <div id="hoverCell"> <wj-flex-grid [itemsSource]="data"></wj-flex-grid> </div> <h2>Hover on Rows</h2> <div id="hoverRow"> <wj-flex-grid [itemsSource]="data"></wj-flex-grid> </div> </div> import { Injectable } from '@angular/core'; interface DataItem { id: number; country: string; downloads: number; sales: number; expenses: number; } @Injectable() export class DataService { getData(): DataItem[] { var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), data = []; for (var i = 0; i < countries.length; i++) { data.push({ id: i, country: countries[i], downloads: Math.round(Math.random() * 20000), sales: Math.random() * 10000, expenses: Math.random() * 5000 }); } return data; } } .wj-flexgrid { height: 150px; margin: 10px 0; } /* css for hovering on non-header cells */ #hoverCell .wj-cells .wj-cell:not(.wj-state-selected):not(.wj-state-multi-selected):hover { background-color:rgb(200,255,200); transition: all 0.5s; } /* css for hovering on non-header rows */ #hoverRow .wj-cells .wj-row:hover .wj-cell:not(.wj-state-selected):not(.wj-state-multi-selected) { transition: all 0.5s; background: rgb(200,255,200); } <template> <div class="container-fluid"> <h2>Hover on Cells</h2> <div id="hoverCell"> <wj-flex-grid :items-source="data"></wj-flex-grid> </div> <h2>Hover on Rows</h2> <div id="hoverRow"> <wj-flex-grid :items-source="data"></wj-flex-grid> </div> </div> </template> <script> import "@grapecity/wijmo.styles/wijmo.css"; import "bootstrap.css"; import Vue from "vue"; import "@grapecity/wijmo.vue2.grid"; import { getData } from "./data"; new Vue({ el: "#app", data: function() { return { data: getData() }; } }); </script> <style> .wj-flexgrid { height: 150px; margin: 10px 0; } /* css for hovering on non-header cells */ #hoverCell .wj-cells .wj-cell:not(.wj-state-selected):not(.wj-state-multi-selected):hover { background-color:rgb(200,255,200); transition: all 0.5s; } /* css for hovering on non-header rows */ #hoverRow .wj-cells .wj-row:hover .wj-cell:not(.wj-state-selected):not(.wj-state-multi-selected) { transition: all 0.5s; background: rgb(200,255,200); } </style> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>GrapeCity Wijmo FlexGrid Hover Styles</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app.vue'); </script> </head> <body> <div id="app"> </div> </body> </html> export function getData() { var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), data = []; for (var i = 0; i < countries.length; i++) { data.push({ id: i, country: countries[i], downloads: Math.round(Math.random() * 20000), sales: Math.random() * 10000, expenses: Math.random() * 5000 }); } return data; } import "@grapecity/wijmo.styles/wijmo.css"; import "bootstrap.css"; import "./app.css"; // import * as React from 'react'; import * as ReactDOM from 'react-dom'; import * as wjcGrid from "@grapecity/wijmo.react.grid"; import { getData } from "./data"; class App extends React.Component { constructor(props) { super(props); this.state = { data: getData() }; } render() { return <div className="container-fluid"> <h2>Hover on Cells</h2> <div id="hoverCell"> <wjcGrid.FlexGrid itemsSource={this.state.data}></wjcGrid.FlexGrid> </div> <h2>Hover on Rows</h2> <div id="hoverRow"> <wjcGrid.FlexGrid itemsSource={this.state.data}></wjcGrid.FlexGrid> </div> </div>; } } ReactDOM.render(<App />, document.getElementById('app')); <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Grapecity Wijmo OLAP Pivot Chart Overview</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- SystemJS --> <script src="node_modules/systemjs/dist/system.src.js"></script> <script src="systemjs.config.js"></script> <script> System.import('./src/app'); </script> </head> <body> <div id="app"></div> </body> </html> .wj-flexgrid { height: 150px; margin: 10px 0; } /* css for hovering on non-header cells */ #hoverCell .wj-cells .wj-cell:not(.wj-state-selected):not(.wj-state-multi-selected):hover { background-color:rgb(200,255,200); transition: all 0.5s; } /* css for hovering on non-header rows */ #hoverRow .wj-cells .wj-row:hover .wj-cell:not(.wj-state-selected):not(.wj-state-multi-selected) { transition: all 0.5s; background: rgb(200,255,200); } export function getData() { var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','), data = []; for (var i = 0; i < countries.length; i++) { data.push({ id: i, country: countries[i], downloads: Math.round(Math.random() * 20000), sales: Math.random() * 10000, expenses: Math.random() * 5000 }); } return data; }