Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Velderon
    @Velderon
    Could you tell me please, is there an easy way to get in my custom pager component such data as: pageIndex, pageSize, dataSource, filterFields, sort, stateKey, afterAsyncFunc, оr I have to pass them by myself?
    Benjamin Cripps
    @bencripps
    Not entirely sure what you're asking -- do you mean when you create the JSX component, or when you're dispatching an action to your custom component?
    Velderon
    @Velderon
    when I create JSX component
    Benjamin Cripps
    @bencripps
    Currently, you will need to pass those props explicitly to the component since it gets generated outside of the component lifecycle (see pager.jsx); I would recommend creating constants for pageIndex, pageSize, and making dataSource a utility that you can import. Since sort and filterFields can be managed as external state variables, there's not an awesome way to get those incorporated as props without the user explicitly passing them.
    That being said, I could see the grrid passing stateKey and pageSize as default props to the custom component.
    I do think that pageIndex will probably need to be managed by your custom component, since that behavior will no longer be triggered by the default grid pager.
    Let me know what you think, and if you'd like to open an issue to get some of these props by default, that sounds good to me, but like I said there are some limitations to what we can probably pass.
    Velderon
    @Velderon
    ok, thanks for the answer. i'm already pass them explicitly, it works fine for me.
    One more question, I have a problem with cyrillic symbols. When I pass them in columns for grid I have an error:
    keyGenerator.js:21 Uncaught DOMException: Failed to execute 'btoa' on 'Window': The string to be encoded contains characters outside of the Latin1 range
    there is an answer on stackoverflow:
    http://stackoverflow.com/questions/23223718/failed-to-execute-btoa-on-window-the-string-to-be-encoded-contains-characte
    it says:
    If you have UTF8, use this (actually works with SVG source), like:
    btoa(unescape(encodeURIComponent(str)))
    And it helped
    Benjamin Cripps
    @bencripps
    Looks like a good solution to me, do you want to make the change and submit a pull request?
    Velderon
    @Velderon
    ok, i will make it.
    Benjamin Cripps
    @bencripps
    great! thanks!
    Velderon
    @Velderon
    Hi.
    There is function setPageAsync in pagerActions where after api request you call dispatch({
    type: PAGE_REMOTE,
    pageIndex: pageIndex,
    stateKey
    });
    it may be necessary to add the same dispatch in setPageIndexAsync after dataSource call, because now when I call setPageIndexAsync action pager doesn't change.
    And also in ColumnManager there is an error in doSort function:
    const pageIndex = pagerState
    && pagerState.get(pageIndex)
    ? pagerState.get(pageIndex)
    : 0;
    so pageIndex always equals 0, so we need to change to like this:
    const pageIndex = pagerState
    && pagerState.get('pageIndex')
    ? pagerState.get('pageIndex')
    : 0;
    after all this fixes we will have an actual pageIndex. And what do you think about passing pageIndex in to dataSource call in doRemoteSort function?
    Also there is almost the same error in ColumnManager in doSort function:
    const pageSize = pagerState
    && pagerState.pageSize
    ? pagerState.pageSize
    : DEFAULT_PAGE_SIZE;
    pageSize always eq to DEFAULT_PAGE_SIZE, I can fix it to. As you advised me I created constant pageSize and use it everywhere I need, but why don't you store it in Pager as well as pageIndex? I can add it as well if it won't break anything.
    Benjamin Cripps
    @bencripps
    agree with the bugs for pageIndex inside these actions, if you can, please submit a pull request to make these changes!
    Velderon
    @Velderon
    so you think that pageSize irrelevant to Pager?
    Benjamin Cripps
    @bencripps
    I don't think it's irrelevant, would you liked it passed as props to the custom pager component? The reason currently no props are passed is that I didn't want to make an assumption about what props a user would want -- however, I'm fine with passing default props like pageSize, pageIndex, and perhaps dataSource.
    Velderon
    @Velderon

    no, I don't want to pass it as a props to custom pager component. There is an action setPageIndexAsync where you call

    dataSource(
                    {pageIndex, pageSize}, filterFields, sort
    )

    I thought than here in doRemoteSort action we could call dataSource as well with the same parameters.

    Benjamin Cripps
    @bencripps
    yeah that sounds reasonable to me
    Natallia
    @algbeta
    Hi @bencripps!
    Why do you need react/react-redux/react-dom in your dependencies?
    I think it should be moved to dev dependencies otherwise two instances of React.js is loaded bc most project which need react-redux-grid already use it.
    What do you think?
    Natallia
    @algbeta
    Natallia
    @algbeta
    I think that's the reason i'm facing bencripps/react-redux-grid#103
    Natallia
    @algbeta
    Since I probably have two different stores... one is in context and a different one from the props