Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onCellValueChanged validate data using FETCH call to server. #3122

Closed
rickysullivan opened this issue May 7, 2019 · 2 comments
Closed

onCellValueChanged validate data using FETCH call to server. #3122

rickysullivan opened this issue May 7, 2019 · 2 comments

Comments

@rickysullivan
Copy link

I'm submitting a ...

[] bug report => see 'Providing a Reproducible Scenario'
[] feature request => do not use Github for feature requests, see 'Customers of ag-Grid'
[*] support request => see 'Requesting Community Support'

Providing a Reproducible Scenario
I'm making a FETCH call to my API server in onCellValueChanged which modifies the server data. I validate sent data on the server and send back the appropriate response.

  handleOnCellValueChanged = async params => {
    const response = await fetch(
      `/api/datacentres/${this.state.dataCentreId}/clients/${
        params.data.Client
      }`,
      {
        method: "PATCH",
        body: JSON.stringify({ [params.column.colId]: params.newValue }),
        headers: {
          "Content-Type": "application/json"
        }
      }
    );

    if (response.ok) {
      //Update cell data.
      params.data[params.column.colId] = params.newValue;
      params.api.stopEditing(false);
    } else {
      //Flash error and keep cell in editing state
    }
  };

I am using a custom React component (basic styled text input) for my cellEditor.

Current behavior

Response of 200 is working well and I have no issues there. The data entered in the editor is rendered when tabbing away from the cell.

The cell value changes, but the data on the server remains unchanged as the payload to my API is rejected from validation (expected). eg.

A payload of a string is sent, but the server rejects a payload because the length of it is greater than accepted.

Expected behavior
If I get a response status of 4xx, then I want show a warning somewhere and not commit the data to the grid, leaving the cell in an editing state.

Please tell us about your environment:
ag-grid in React

  • ag-Grid version: 20.0.0
  • Browser:
    ALL

  • Language: ES6/7

@makinggoodsoftware
Copy link
Contributor

Hi,

ag-grid staff does not provide support through github. If you are a customer please contact us through our official support channel. Note that this issue has been flagged as managed-by-the-community, we also recommend you to check stackoverflow, note that if there is no activity on this issue after a while we will close it.

Thanks

@rickysullivan
Copy link
Author

This is basically a pre-sales question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants