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

Sorting on grouped colum with null values #3271

Closed
valepu opened this issue Apr 13, 2015 · 2 comments · Fixed by #3431
Closed

Sorting on grouped colum with null values #3271

valepu opened this issue Apr 13, 2015 · 2 comments · Fixed by #3431
Assignees
Milestone

Comments

@valepu
Copy link
Contributor

valepu commented Apr 13, 2015

Hi,
If i try to sort a grouped colum that contains null values i receive this error:

"Error: groupingProcessingState[i].currentGroupHeader is null
service.setVisibility@http://localhost/resources/angularjs/grid-3.0.0-rc.20/ui-grid-unstable.js:17249:1
service.groupRows@http://localhost/resources/angularjs/grid-3.0.0-rc.20/ui-grid-unstable.js:16998:13
startProcessor@http://localhost/resources/angularjs/grid-3.0.0-rc.20/ui-grid-unstable.js:4163:23
handleProcessedRows@http://localhost/resources/angularjs/grid-3.0.0-rc.20/ui-grid-unstable.js:4179:20
Ae/e/l.promise.then/F@http://localhost/resources/angularjs/v1.2.26/angular.min.js:100:178
Ae/e/l.promise.then/F@http://localhost/resources/angularjs/v1.2.26/angular.min.js:100:178
Ae/f/<.then/<@http://localhost/resources/angularjs/v1.2.26/angular.min.js:101:350
Zd/this.$get</k.prototype.$eval@http://localhost/resources/angularjs/v1.2.26/angular.min.js:112:64
Zd/this.$get</k.prototype.$digest@http://localhost/resources/angularjs/v1.2.26/angular.min.js:109:160
Zd/this.$get</k.prototype.$evalAsync/<@http://localhost/resources/angularjs/v1.2.26/angular.min.js:112:177
e@http://localhost/resources/angularjs/v1.2.26/angular.min.js:37:495
te/k.defer/c<@http://localhost/resources/angularjs/v1.2.26/angular.min.js:41:235
"

on Chrome the error is (which is the same error, in the end, just with a different wording)

TypeError: Cannot read property 'expandedState' of null
at Object.service.setVisibility (ui-grid-unstable.js:17249)
at Grid.service.groupRows (ui-grid-unstable.js:16998)
at startProcessor (ui-grid-unstable.js:4163)
at handleProcessedRows (ui-grid-unstable.js:4179)
at l.promise.then.F (angular.js:11573)
at l.promise.then.F (angular.js:11573)
at angular.js:11659
at k.$get.k.$eval (angular.js:12702)
at k.$get.k.$digest (angular.js:12514)
at angular.js:12740

This happens either by clicking on the column header or by chosing the sorting from the column menu.

The same error happens if i try to group a column which the first row has a null value. In this case the grouping happens but the grid doesn't change unless i do some action (like adding another grouping or sorting or filtering)

@valepu
Copy link
Contributor Author

valepu commented Apr 13, 2015

As a temporary solution i did this, which shows an underscore for blank values. Maybe it'd be useful to be able to specify a default value for each column when a cell value is null

  Grid.prototype.getCellValue = function getCellValue(row, col){
    if (this.options.flatEntityAccess && col.field){
      //EDITED
      if(row.entity[col.field]==null){
        row.entity[col.field]="";
      }
      return row.entity[col.field];      
    } else {
      if (!col.cellValueGetterCache) {
        col.cellValueGetterCache = $parse(row.getEntityQualifiedColField(col));
      }
      //EDITED
      if(col.cellValueGetterCache(row)==null){
        return "";
      }

      return col.cellValueGetterCache(row);
    }
  };

@valepu valepu changed the title Sorting on grouped colum with blank values Sorting on grouped colum with null values Apr 17, 2015
@AgDude
Copy link
Contributor

AgDude commented May 5, 2015

I have generated a plunk to look at null values in grouping: http://plnkr.co/edit/UhJTvq?p=preview

I have found that setting a "state" value to null or omitting it, is causing the grid to completely fail to generate (with the error stated by the OP).

@PaulL1 PaulL1 added this to the 3.1 milestone May 5, 2015
@PaulL1 PaulL1 self-assigned this May 5, 2015
AgDude pushed a commit to AgDude/ui-grid that referenced this issue May 6, 2015
AgDude pushed a commit to AgDude/ui-grid that referenced this issue May 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants