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

render function for grid column ran twice #2086

Open
james-yong opened this issue Aug 27, 2021 · 3 comments
Open

render function for grid column ran twice #2086

james-yong opened this issue Aug 27, 2021 · 3 comments
Labels
Bug This needs fixing Reproducer: Present This PR or issue contains code, which reproduce the problem described or clearly understandable MCVE

Comments

@james-yong
Copy link
Contributor

james-yong commented Aug 27, 2021

Short description
Custom render function for grid column is run twice instead of once, per row index and col_index.
Affects both master and 1.5 versions.

What is current behavior

[Log] list::0::8 (test.html, line 65)
[Log] list::1::8 (test.html, line 65)
[Log] list::2::8 (test.html, line 65)
[Log] list::3::8 (test.html, line 65)
[Log] list::4::8 (test.html, line 65)
[Log] list::5::8 (test.html, line 65)
[Log] list::6::8 (test.html, line 65)
[Log] list::7::8 (test.html, line 65)
[Log] list::8::8 (test.html, line 65)
[Log] list::0::8 (test.html, line 65)
[Log] list::1::8 (test.html, line 65)
[Log] list::2::8 (test.html, line 65)
[Log] list::3::8 (test.html, line 65)
[Log] list::4::8 (test.html, line 65)
[Log] list::5::8 (test.html, line 65)
[Log] list::6::8 (test.html, line 65)
[Log] list::7::8 (test.html, line 65)
[Log] list::8::8 (test.html, line 65)

What is desired behavior

[Log] list::0::8 (test.html, line 65)
[Log] list::1::8 (test.html, line 65)
[Log] list::2::8 (test.html, line 65)
[Log] list::3::8 (test.html, line 65)
[Log] list::4::8 (test.html, line 65)
[Log] list::5::8 (test.html, line 65)
[Log] list::6::8 (test.html, line 65)
[Log] list::7::8 (test.html, line 65)
[Log] list::8::8 (test.html, line 65)

Link to jsfidle/codepan with sample code

{ field: 'list', text: 'list', size: '50%', sortable: true, resizable: true,
editable: { type: 'list', items: people, showAll: true },
render: function (record, index, col_index) {
console.log(list::${index}::${col_index});
var html = this.getCellValue(index, col_index);
return html || '';
}
},

Steps to reproduce or sample
Copy the code from http://w2ui.com/web/demos/#/grid/21
Add console.log(list::${index}::${col_index}); to line 65.
Check the browser console after loading the page.

@mpf82
Copy link
Collaborator

mpf82 commented Aug 30, 2021

ACK, calling w2ui.grid.refresh() calls the render function twice.

Fiddle: http://jsfiddle.net/Lqac1y52/

Needs further investigation.

@mpf82 mpf82 added Bug This needs fixing Reproducer: Present This PR or issue contains code, which reproduce the problem described or clearly understandable MCVE labels Aug 30, 2021
@vitmalina
Copy link
Owner

I do not see it run twice int he fiddle provided above. Here is console.log I see
Screen Shot 2021-10-04 at 8 31 29 AM
Which is correct. One time per each row.

May be there is a second refresh call somewhere. For example after it returns from the server?

@mpf82
Copy link
Collaborator

mpf82 commented Oct 4, 2021

True, I no longer see it rendering twice either, but it was definitely there.

However, the renderer seems to be executed twice when the grid is initially loaded, so there might be an unnecassry call nonetheless that might be worth investigating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This needs fixing Reproducer: Present This PR or issue contains code, which reproduce the problem described or clearly understandable MCVE
Projects
None yet
Development

No branches or pull requests

3 participants