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

Custom column/template not being rendered after v3.0.7 #4532

Closed
lebolo opened this issue Oct 16, 2015 · 6 comments · Fixed by #4902
Closed

Custom column/template not being rendered after v3.0.7 #4532

lebolo opened this issue Oct 16, 2015 · 6 comments · Fixed by #4902

Comments

@lebolo
Copy link
Contributor

lebolo commented Oct 16, 2015

After updating to v3.0.7, one of my columns (which makes use of custom headerCellTemplate and cellTemplate in the column definition) is no longer being rendered (the column shows up blank and there is no HTML for it).

The column is initially pinned to the left (pinnedLeft: true in column definition) and I use it as a custom selection column (one that I can control the filtering/behavior of). The templates are based on the default templates with minor differences.

The related change is #4428 (see issue #4386). Particularly here:

Before
// If we either have some columns defined, or some data defined
if (self.grid.options.columnDefs.length > 0 || newData.length > 0) {
  // Build the column set, then pre-compile the column cell templates
  promises.push(self.grid.buildColumns()
    .then(function() {
      self.grid.preCompileCellTemplates();
    }));
}
After
// If we haven't built columns before and either have some columns defined or some data defined
if (!hasColumns && (self.grid.options.columnDefs.length > 0 || newData.length > 0)) {
  // Build the column set, then pre-compile the column cell templates
  promises.push(self.grid.buildColumns()
    .then(function() {
      self.grid.preCompileCellTemplates();
    }));
}

If I remove !hasColumns from the if statement, my column renders again. Is the logic being implemented wrong? I don't understand enough about what @oriondean was trying to do here.

@rhrasna
Copy link

rhrasna commented Nov 9, 2015

I have the same problem after upgrade to 3.0.7. Modifying condition as lebolo suggested works.

@oriondean
Copy link
Contributor

Hey, @lebolo @rhrasna , do you have any reproduction examples of this issue?

@lebolo
Copy link
Contributor Author

lebolo commented Nov 14, 2015

Hey @oriondean, thanks for taking a look at this.

I set up a plunker that reproduces the problem (column header is not rendering). In index.html, you can switch the versions of the css/js scripts from 3.0.7 to 3.0.6 to see the difference.

I dummied down the custom selection column functionality, so you'll see some superfluous code around filtering.

Let me know if you have any questions!

@lebolo
Copy link
Contributor Author

lebolo commented Nov 30, 2015

Hi @oriondean, just pinging. Did you or anyone else get a chance to look at this?

@oriondean
Copy link
Contributor

I've taken a initial look, It seems to be a race condition dependent on how long it takes to load the cell template. Sometimes, the columns are built before the template has loaded.

Unfortunately, I've not had time yet to implement a solution to this problem

@oriondean
Copy link
Contributor

I've identified the issue and implemented a fix.

Once the template was retrieved from the URL, it was setting the grid data to when the request was first made, rather than using the most recent value.

The guard I introduced saved on some unnecessary calls to buildColumns and preCompileCellTemplates. These calls were always made after the template was retrieved and used the most recent grid data.

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

Successfully merging a pull request may close this issue.

3 participants