-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #301 from komarovalexander/extended-data-processing
Add extendedSort option
- Loading branch information
Showing
10 changed files
with
231 additions
and
620 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var ghpages = require('gh-pages'); | ||
|
||
ghpages.publish('build', function(err) {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import SortingExtendedDemo from './SortingExtendedDemo'; | ||
|
||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
ReactDOM.render(<SortingExtendedDemo />, div); | ||
ReactDOM.unmountComponentAtNode(div); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { DataType, Table } from '../../lib'; | ||
import { SortDirection, SortingMode } from '../../lib/enums'; | ||
|
||
import React from 'react'; | ||
import orderBy from 'lodash.orderby'; | ||
|
||
const dataArray: any[] = [ | ||
{ id: 1, name: 'Mike Wazowski', score: 80, passed: true, faculty: 'Economics', comment: 'Well done!' }, | ||
{ id: 2, name: 'Billi Bob', score: 55, passed: false, faculty: 'Engineering', comment: 'almost did it, keep going' }, | ||
{ id: 3, name: 'Tom Williams', score: 45, passed: false, faculty: 'Engineering', comment: 'you can do it better' }, | ||
{ id: 4, name: 'Kurt Cobain', score: 75, passed: true, faculty: 'Economics', comment: 'Well done!' }, | ||
{ id: 5, name: 'Marshall Bruce', score: 77, passed: true, faculty: 'Mathematics', comment: 'Well done!' }, | ||
{ id: 6, name: 'Sunny Fox', score: 33, passed: false, faculty: 'Mathematics', comment: 'It was just a bad day :)' }, | ||
]; | ||
|
||
const SortingExtendedDemo: React.FC = () => { | ||
return ( | ||
<Table | ||
columns= {[ | ||
{ | ||
dataType: DataType.Boolean, | ||
key: 'passed', | ||
sortDirection: SortDirection.Ascend, | ||
style: {width: 90}, | ||
title: 'Passed', | ||
}, | ||
{ | ||
dataType: DataType.String, | ||
key: 'name', | ||
style: {width: 100}, | ||
title: 'Name', | ||
}, | ||
{ | ||
dataType: DataType.Number, | ||
key: 'score', | ||
style: {width: 120}, | ||
title: 'Score', | ||
}, | ||
{ | ||
dataType: DataType.String, | ||
key: 'faculty', | ||
style: {width: 150}, | ||
title: 'Faculty (Custom icon)', | ||
}, | ||
{ | ||
dataType: DataType.String, | ||
key: 'comment', | ||
style: {width: 150}, | ||
isSortable: false, | ||
title: 'Comment (sorting disabled)', | ||
} | ||
]} | ||
data={dataArray} | ||
format= {({ column, value }) => { | ||
if (column.key === 'prevScores'){ | ||
return value.join(); | ||
} | ||
}} | ||
extendedSort={(data, columns) => { | ||
let sortedColumns = columns.filter(c => c.sortDirection); | ||
if (sortedColumns.length === 0){ | ||
return data; | ||
} | ||
sortedColumns = orderBy(sortedColumns, ['sortIndex'], ['asc']); | ||
const iteratee = sortedColumns.map(c => c.key); | ||
const order = sortedColumns.map(c => c.sortDirection === SortDirection.Ascend ? 'asc' : 'desc'); | ||
return orderBy(data, iteratee, order); | ||
}} | ||
rowKeyField={'id'} | ||
sortingMode={SortingMode.MultipleTripleStateRemote} | ||
/> | ||
); | ||
}; | ||
|
||
export default SortingExtendedDemo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.