Comments (25)
released as 2.2.6
from react-redux-grid.
Instead of importing your reducers like:
import { Reducers } from 'react-redux-grid';
const gridReducers = {
dataSource: Reducers.DataSource,
editor: Reducers.Editor,
errorHandler: Reducers.ErrorHandler,
filter: Reducers.Filter,
grid: Reducers.grid,
loader: Reducers.Loader,
menu: Reducers.Menu,
pager: Reducers.Pager,
selection: Reducers.Selection,
};
export default combineReducers({
facility,
language,
routing,
form,
..gridReducers,
});
you will simply do this:
import { Reducers as gridReducers } from 'react-redux-grid';
export default combineReducers({
facility,
language,
routing,
form,
...gridReducers,
});
from react-redux-grid.
hey @innopal, could you create new issues for these? Since this is a closed issue, and you're addressing other features/bugs, it's probably best to open as another issue. Thanks!
from react-redux-grid.
Do you want a custom remote
sort or a custom local
sort?
from react-redux-grid.
Sorry I didn't clarify! Just local sort. For example I have date columns I need to sort asc and desc.
from react-redux-grid.
No this feature hasn't been implemented yet. I'll keep this issue open and get to it as soon as I can.
from react-redux-grid.
Thanks for adding the feature to your backlog.
Any workaround you can think of in the meantime? Any event that can intercept sorting a column (with proper payload incl. column and sort direction)?
Cheers.
from react-redux-grid.
Each header definition has the event HANDLE_CLICK
;
on the fire of this event, you could simply use the Actions.GridActions.setData
method to set the grid data with the newly sorted data. Just a thought.
I would set this column to not be sortable -- as far as overriding the class -- not sure if that would work. I can probably get to this feature relatively soon.
from react-redux-grid.
@innopal so does the default local sorting that comes by default doesn't work for you, since these are dates, is that correct?
from react-redux-grid.
Yeah primarily, if the data is date type it doesn't sort correctly. I need to be able to add my own sorting like:
mylist.sort((a, b) => (moment(a) - moment(b)))
from react-redux-grid.
ok cool, this should be fairly simple to implement. it should be done and pushed within the next couple days.
from react-redux-grid.
This is done.
On the column you'd like to be able to custom sort, you will need to add the following:
const columns = [
{
name: 'Column with custom Sort',
dataIndex: 'sortable',
sortable: true
sortFn: (a, b) => {
// your sort logic
}
},
// ... rest of columns
];
from react-redux-grid.
Thanks @bencripps,
It doesn't work though! It doesn't fire sortFn at all.
Cheers.
from react-redux-grid.
Hmm, I wrote a test around it, and I just ran the tests/ ran through it in a browser and it seems to work. If you put a debugger in the sortFn, it doesn't get called?
from react-redux-grid.
Nope! it doesn't.
from react-redux-grid.
on the column, is sortable: true
set?
from react-redux-grid.
@innopal let me know if that fixed your issue, otherwise could you send me the column definition?
from react-redux-grid.
Hi Ben,
Sorry I was MIA for a while.
As I mentioned I never managed to get sortFn to fire. And yes, sortable is true.
I'm getting all sorts of error now. Any ideas what's happening here?
Here are some warnings and error I get back to back:
Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of Row
. See https://fb.me/react-warning-keys for more information.
Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method of EmptyCell
.
Uncaught Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. Check the render method of EmptyCell
.
from react-redux-grid.
Hmm, that's a whole bunch of errors -- I also can't reproduce the sortFn
not firing. Could you find the simplest version of your grid implementation and send it to me? I can debug it from there, and see whats going on.
from react-redux-grid.
Hi @bencripps,
Now I can get the sortFn to work, so thanks for the feature.
However, it doesn't have a direction (asc/desc) parameter, hence, toggling doesn't work and it always sorts one way.
Any ideas?
from react-redux-grid.
That's a good point, I will pass the direction into the function. I'll push a commit to master and you can test.
from react-redux-grid.
Should work now -- direction will be the first argument, and will either be DESC
OR ASC
. Here's an example of how this could work.
const sortFn = (direction, prev, curr) => {
if (direction === 'DESC') {
return prev - curr;
}
return curr - prev;
};
from react-redux-grid.
@bencripps, master branch works great! Any release plans?
from react-redux-grid.
Hey Ben @bencripps,
Did you just camelCased all the reducers in 2.3.0?
from react-redux-grid.
@bencripps
Hi Ben,
I'm trying to keep the last state that grid was sorted on in my redux store.
Something like:
{
dataIndex: 'name',
direction: 'DESC'
}
Is there any event that I can intercept to record that state each time, a sort is fired?
Cheers
from react-redux-grid.
Related Issues (20)
- how to refresh with remote dataSource from another action HOT 2
- Custom look of GRID_ACTIONS elements
- Assigning a property of sortable: true and defaultSortDirection: ASC|DESC does not sort the table by default HOT 1
- EditorActions.addNewRow documentation or sample code HOT 2
- Align header columns with table's contents HOT 2
- Nested Grids using react-redux-grid
- Nested object property as column value HOT 2
- PropTypes (oneOf) error when loading the Grid
- Include react-redux-grid in existing project where also uses HTML5 backend causes problem.
- Include react-redux-grid in existing project where also uses HTML5 backend causes problem. HOT 1
- Unable to remove "Edit" item from grid actions HOT 2
- Is there a way to prevent a node from moving? HOT 3
- Pass store to Grid HOT 3
- incorrect selection of indexes when selecting row
- Is there a way to add custom edit/delete button?
- too small select checkbox
- @types/react-redux-grid HOT 1
- rowIndex in tree mode
- Tree, selection throwing an mutation exception on action @@react-redux-grid/SET_SELECTION
- Instead of disabling actions can we hide it from the the action menu? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-redux-grid.