Author Topic: bug in treegrid  (Read 711 times)

hyh888

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 142
    • View Profile
bug in treegrid
« on: September 27, 2023, 06:00:48 am »
When the pid of the top root node in treegrid is 0( for the database in my company required that pid field couldn't be null.), the treegrid couldn't be show out.
When I tried modify the response data which come from server, it wil make a lot of trouble in select box in treegrid.
Is there any way to fix the bug?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6309
    • View Profile
Re: bug in treegrid
« Reply #1 on: December 21, 2023, 11:29:29 am »
root node is suppoed to have undefined pid.

0 is not the same as undefined so it's not a bug,

hyh888

  • Pro Enterprise
  • Full Member
  • *
  • Posts: 142
    • View Profile
Re: bug in treegrid
« Reply #2 on: February 27, 2024, 02:39:18 pm »
I have to make a patch like this to solve two in-build problem of tree.

        function getChanges(grid) {

            let list =grid.getChanges({ format: 'byVal' });

            list.addList.forEach(item => {
                delete item.id;
                if(!item.pid)item.pid=0;
            });
            list.updateList.forEach(item => {
                 delete item.items;
                if(!item.pid)item.pid=0;
            });

            return list;
        }