Git Product home page Git Product logo

Comments (4)

bencripps avatar bencripps commented on May 29, 2024

You are correct, the demo data doesn't have any rest functionality. I like your enhancement request, but this is a big change so ideally I'd like to think about it some before making these changes.

The best pattern for this is:

constants.js;

export const API_READ = 'api/read/route';
export const API_UPDATE = 'api/update/route';
export const API_DELETE = 'api/delete/route'; 

grid.js

import { GridActions } from 'react-redux-grid';
import { apiDelete, apiRead } from './api';

const config = {
    plugins: {
         GRID_ACTIONS: {
             menu: [
                {
                    text: 'delete',
                    EVENT_HANDLER: ({ store, metaData }) => {
                        apiDelete(metaData).then(() => {
                            store.dispatch(
                                GridActions.DataSource.getAsyncData({
                                    stateKey: 'my-grid',
                                    dataSource: apiRead
                                });
                            );
                        })
                    }
                }
             ]
         }
    }
};

I like the idea of making the dataSource an object with three keys, but it also seems a little more restrictive than the current design. Like I said, I'm going to think about it for a bit.

from react-redux-grid.

kkwak avatar kkwak commented on May 29, 2024

minus a couple typos, that worked for me.
import { Actions } from 'react-redux-grid' Actions.GridActions.getAsyncData(...)
also "store" doesn't get passed in to the EVENT_HANDLER. I had to bring it in scope, which isn't a big deal.

I need a way to "ADD" to rows to the grid in edit mode - if you have ideas, let me know..

I'm going through the codebase, but it's quite large and I'm not a js dev.

from react-redux-grid.

bencripps avatar bencripps commented on May 29, 2024

There is an addRow action exposed by the grid.

export function addNewRow({ columns, data, stateKey }) {

    return (dispatch) => {
        const rowId = keyGenerator('row', 0);
        const top = 43;
        const rowData = data || {};
        const rowIndex = 0;
        const isCreate = true;

        dispatch({ type: ADD_NEW_ROW, stateKey });

        dispatch(
            editRow({
                rowId,
                top,
                rowData,
                rowIndex,
                columns,
                isCreate,
                stateKey
            })
        );
    };
}

You can pass rowData to it, so the new row will be populated with that data, otherwise it will be empty.

from react-redux-grid.

kkwak avatar kkwak commented on May 29, 2024

works perfectly - I suppose these actions are meant to be the api of the grid.. thanks!

from react-redux-grid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.