react-virtualized#SortIndicator JavaScript Examples
The following examples show how to use
react-virtualized#SortIndicator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VirtualizedTable.js From sampo-ui with MIT License | 4 votes |
render () {
const { classes, list, perspectiveID } = this.props
// console.log(list)
const rowGetter = ({ index }) => this._getDatum(list, index)
const headerRenderer = ({
dataKey,
label,
sortBy,
sortDirection
}) => {
const showSortIndicator = sortBy === dataKey
const children = [
<span
className='ReactVirtualized__Table__headerTruncatedText'
style={showSortIndicator ? {} : { marginRight: 16 }}
key='label'
title={label}
>
{label}
</span>
]
if (showSortIndicator) {
children.push(
<SortIndicator key='SortIndicator' sortDirection={sortDirection} />
)
}
return children
}
const labelRenderer = ({ cellData, rowData }) => {
if (cellData == null) return ''
const label = <a target='_blank' rel='noopener noreferrer' href={rowData.id}>{cellData}</a>
let marker = ''
if (typeof rowData.lat !== 'undefined' || typeof rowData.long !== 'undefined') {
marker = (
<IconButton disabled aria-label='Marker' size="large">
<PlaceIcon />
</IconButton>
)
}
return (
<div key={rowData.id}>
{label}{marker}
</div>
)
}
const sourceRenderer = ({ cellData, rowData }) => {
if (cellData == null) return ''
if (has(rowData, 'namesArchiveLink')) {
return (
<div key={rowData.s}>
<a target='_blank' rel='noopener noreferrer' href={rowData.namesArchiveLink}>{cellData}</a>
</div>
)
} else {
return (
<div key={rowData.s}>{cellData}</div>
)
}
}
return (
<div className={classes.root}>
{this.props.list.size > 0 &&
<AutoSizer>
{({ height, width }) => (
<Table
overscanRowCount={10}
rowHeight={40}
rowGetter={rowGetter}
rowCount={this.props.list.size}
sort={this._sort}
sortBy={this.props.clientFSState.sortBy}
sortDirection={this.props.clientFSState.sortDirection.toUpperCase()}
width={width}
height={height}
headerHeight={50}
noRowsRenderer={this._noRowsRenderer}
style={tableStyles.tableRoot}
rowStyle={calculateRowStyle}
>
<Column
label={intl.get(`perspectives.${perspectiveID}.properties.prefLabel.label`)}
cellDataGetter={({ rowData }) => rowData.prefLabel}
dataKey='prefLabel'
headerRenderer={headerRenderer}
cellRenderer={labelRenderer}
width={columnWidth + 70}
/>
<Column
label={intl.get(`perspectives.${perspectiveID}.properties.broaderTypeLabel.label`)}
cellDataGetter={({ rowData }) => has(rowData, 'broaderTypeLabel') ? rowData.broaderTypeLabel.toLowerCase() : ''}
dataKey='broaderTypeLabel'
headerRenderer={headerRenderer}
width={columnWidth + 10}
/>
{/* <Column
label="NA type"
cellDataGetter={({rowData}) => has(rowData,'typeLabel') ? rowData.typeLabel.toLowerCase() : ''}
dataKey="typeLabel"
headerRenderer={headerRenderer}
width={columnWidth}
/> */}
<Column
label={intl.get(`perspectives.${perspectiveID}.properties.broaderAreaLabel.label`)}
cellDataGetter={({ rowData }) => rowData.broaderAreaLabel}
dataKey='broaderAreaLabel'
headerRenderer={headerRenderer}
width={columnWidth}
/>
<Column
label={intl.get(`perspectives.${perspectiveID}.properties.modifier.label`)}
cellDataGetter={({ rowData }) => rowData.modifier}
dataKey='modifier'
headerRenderer={headerRenderer}
width={columnWidth + 10}
/>
<Column
label={intl.get(`perspectives.${perspectiveID}.properties.basicElement.label`)}
cellDataGetter={({ rowData }) => rowData.basicElement}
dataKey='basicElement'
headerRenderer={headerRenderer}
width={columnWidth}
/>
{/*
<Column
label="Collector"
cellDataGetter={({rowData}) => rowData.collector}
dataKey="collector"
headerRenderer={headerRenderer}
width={columnWidth}
/> */}
<Column
label={intl.get(`perspectives.${perspectiveID}.properties.collectionYear.label`)}
cellDataGetter={({ rowData }) => rowData.collectionYear}
dataKey='collectionYear'
headerRenderer={headerRenderer}
width={columnWidth}
/>
<Column
label={intl.get(`perspectives.${perspectiveID}.properties.source.label`)}
cellDataGetter={({ rowData }) => rowData.source}
dataKey='source'
headerRenderer={headerRenderer}
cellRenderer={sourceRenderer}
width={columnWidth}
/>
</Table>
)}
</AutoSizer>}
</div>
)
}