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

Bugs in TreeTable #7511

Closed
ol2ka opened this issue Apr 5, 2019 · 3 comments
Closed

Bugs in TreeTable #7511

ol2ka opened this issue Apr 5, 2019 · 3 comments

Comments

@ol2ka
Copy link

ol2ka commented Apr 5, 2019

I'm submitting a ... (check one with "x")

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)
https://stackblitz.com/github/ol2ka/primeng-issues

Current behavior

  1. Toggle all () doesn't work if p-treeTable dataKey property is used (e.g. <p-treeTable dataKey="name").
    The root node is not selected in this case and nothing happens if I click second time.

  2. Custom sorting of tree table doesn't seem to work at all. I just copied the sort function from the example in the documentation, and nothing happens when I try to sort.

Expected behavior
Works as designed.

Minimal reproduction of the problem with instructions

  1. Just use "dataKey" property for the p-treeTable and try to use p-treeTableHeaderCheckbox

  2. (sortFunction)="customSort($event)" [customSort]="true"
    customSort(event: SortEvent) {
    console.log('event', event)
    //event.data = Data to sort
    //event.mode = 'single' or 'multiple' sort mode
    //event.field = Sort field in single sort
    //event.order = Sort order in single sort
    //event.multiSortMeta = SortMeta array in multiple sort

     event.data.sort((data1, data2) => {
         let value1 = data1[event.field];
         let value2 = data2[event.field];
         let result = null;
    
         if (value1 == null && value2 != null)
             result = -1;
         else if (value1 != null && value2 == null)
             result = 1;
         else if (value1 == null && value2 == null)
             result = 0;
         else if (typeof value1 === 'string' && typeof value2 === 'string')
             result = value1.localeCompare(value2);
         else
             result = (value1 < value2) ? -1 : (value1 > value2) ? 1 : 0;
    
         return (event.order * result);
     });
    

    }

  • Angular version: 7.1.1
  • PrimeNG version: 7.1.0
  • Browser: [all | Chrome | Firefox |Safari ]
@dregos
Copy link

dregos commented Jul 30, 2019

I have a similar problem. Treetable customSort property does not bind.

Can't bind to 'customSort' since it isn't a known property of 'ng-template'.

Angular version : 8.0.1
PrimeNG version: 8.0.2

@cagataycivici
Copy link
Member

Unable to replicate with PrimeNG 9, if the issue persists please create a new ticket with a test case reproducing the issue e.g. stackblitz or a github repo and it will be reviewed by our team once again.

@nerg4l
Copy link

nerg4l commented Sep 28, 2020

At my company we are using version 7.1.3 of PrimeNG. With some logging I could figure out that data1 and data2 are objects with the following structure:

{
  data: {/* row object here */},
  parent?: {/* parent object here */},
  children: [],
  expanded: true,
}

Which means, instead of data1[event.field] you have to use data1.data[event.field].

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

No branches or pull requests

4 participants