DataTable Templating

UI Components for React
Post Reply
rcapozza
Posts: 4
Joined: 11 Mar 2022, 20:27

20 Jun 2022, 17:31

Hi guys, What could be the reasons why the functions implemented for body datatable templating are executed twice for each row. Thanks in advance for the help.

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

20 Jun 2022, 17:35

To me it sounds like `render` is being called twice if you are seeing it executed twice. Or is it 2 rows of data executed once for each row?
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 11.0.3 / PF Extensions 11.0.3
PrimeReact 8.0.0

rcapozza
Posts: 4
Joined: 11 Mar 2022, 20:27

20 Jun 2022, 18:15

Thanks for taking care Melloware, it's a row executed twice. the execution is like this, all the rows are rendered in the corresponding cell, a component is rendered (more specifically a sparkline type graph) according to the data of the row and finally all the rows are rendered again. Best regards Ricardo

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

20 Jun 2022, 20:13

Hmmm if you can create a Code Sandbox reproducer it would help me see the issue: https://codesandbox.io/s/primereact-test-forked-bbns8k
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 11.0.3 / PF Extensions 11.0.3
PrimeReact 8.0.0

rcapozza
Posts: 4
Joined: 11 Mar 2022, 20:27

20 Jun 2022, 21:31

I modified

https://codesandbox.io/s/patient-fog-e ... 1009-1026

Code: Select all

const imageBodyTemplate = (rowData) => {
    console.log("Cell update " + rowData.name);
    return (
      <img
        src={`images/product/${rowData.image}`}
        onError={(e) =>
          (e.target.src =
            "https://www.primefaces.org/wp-content/uploads/2020/05/placeholder.png")
        }
        alt={rowData.image}
        className="product-image"
      />
    );
  };
in such a way that each pass through the imageBodyTemplate function is shown in the console, and as you can see the function is executed 10 times for each of the rows of the table and then 10 more times. Is this behavior normal, what is the reason for the second pass?

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

21 Jun 2022, 18:45

Huh i would report this on GitHub issues and make sure to include your Code Sanbox reproducer. I am not sure why its rendering everything twice.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 11.0.3 / PF Extensions 11.0.3
PrimeReact 8.0.0

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

21 Jun 2022, 18:50

OK neverminded try my sandbox: https://codesandbox.io/s/awesome-chaum- ... ingDemo.js

On PF 8.1.1 its fixed it only renders once.
PrimeFaces Developer | PrimeFaces Extensions Developer
GitHub Profile: https://github.com/melloware
PrimeFaces Elite 11.0.3 / PF Extensions 11.0.3
PrimeReact 8.0.0

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests