Not able to edit cell in Primereact Datatable

UI Components for React
Post Reply
adibaliga
Posts: 2
Joined: 04 May 2022, 08:27

04 May 2022, 09:04

Im using same lazy load example of primereact https://www.primefaces.org/primereact/datatable/lazy/ and
using datatable edit https://www.primefaces.org/primereact/datatable/edit/tried to edit cells.
Columns I have used for datatable are Name,Country,Company and Representative
I have used below codes for trying to achieve cell edit

Code: Select all

  const onCellEditChange = (options) => (event) => {
    options.editorCallback(event.target.value);
  };
  const cellEditor = (options) => {
    return (
      <InputText
        value={options.value}
        onChange={onCellEditChange(options)}
      />
    );
  };
  const onCellEditComplete = (e) => {
    let { rowData, newValue, field, originalEvent: event } = e;
    if (newValue.trim().length > 0) 
      rowData[field] = newValue;
     else 
      event.preventDefault();
  };
<Column 
..
..
  editor={(options) => cellEditor(options)}
        onCellEditComplete={onCellEditComplete}
      />
      
I'm able to edit Name and Company cells but not Country and representative cells

Melloware
Posts: 3716
Joined: 22 Apr 2013, 15:48

05 May 2022, 22:12

Its because Country is an object not just a plain string like the other two fields.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 13.0.0 / PF Extensions 13.0.0
PrimeReact 9.6.1

adibaliga
Posts: 2
Joined: 04 May 2022, 08:27

11 May 2022, 14:34

Ok Thanks for the reply

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests