Git Product home page Git Product logo

Comments (6)

debabratapatra avatar debabratapatra commented on June 17, 2024

@tarangsachdev92 by chaning this.data will not reflect on the grid. You need to assign a new array to this.data . You can add a row using inbuilt add feature. Right now there is no option to add a row dynamically. I will see if I can add this feature over the weekend.

from angular-tree-grid.

tarangsachdev92 avatar tarangsachdev92 commented on June 17, 2024
this.data = [
              ...this.data,
              {
                id: 16,
                name: "Mayur",
                age: 20,
                weight: 20,
                gender: 1,
                phone: 7930343463,
                parent: 10
              }
            ];
            for (const da of this.data) {
              if (da.expanded) {
                this.ref.detectChanges();
                this.expandRow(da.id);
                this.ref.detectChanges();
              }
            }

I am able to push that row in this.data
by above code I am able to add new row dynamically,

may be you got me wrong.my concern is little bit different.

I looped through this.data and if (row) is alredy expanded before, then I want that row expanded after adding.

this.expandRow(da.id); with this code I am expecting the row expand but it expand me all the child row of first row.

from angular-tree-grid.

debabratapatra avatar debabratapatra commented on June 17, 2024

Okay. I see you are assigning new array to this.data and that will add new row. So basically what it thinks, it got a new Array so it tries to refresh the grid. I think maybe before updating this.data, you can track which rows are expanded then after few seconds(setTimeout?) you can try to expand those rows via expandRow. setTimeout is not Ideal here but you can try. I will see if I can fire some events when grid is ready to be updated.

from angular-tree-grid.

tarangsachdev92 avatar tarangsachdev92 commented on June 17, 2024

you can again check provided stackblitz and Screen Recording for better understanding.

with my code I can able to expand row (which I had tracked on click of expand button and collapse button).

// in this code I have add expanded property with boolean value)
onCollapse(e) {
    const rowData = e.data;
    this.data.map(elem => {
      if (elem.id === rowData.id || elem.parent === rowData.id) {
        elem.expanded = false;
      }
      return elem;
    });
  }

  onExpand(e) {
    const rowData = e.data;
    this.data.map(elem => {
      elem.expanded = elem.expanded || elem.id === rowData.id;
      return elem;
    });
  }

and as in previous reply I looped thorugh and identify which row is epanded and I called

    this.angularGrid.expandRow(id);

this is working good in some condition but this is not working as expected for the steps which are descirbed in a question.

this code expand the row but it's child also gets expanded(before add it(child) was not expanded).

from angular-tree-grid.

debabratapatra avatar debabratapatra commented on June 17, 2024

@tarangsachdev92 I have pushed a fix. Try latest version and let me know if this works.

from angular-tree-grid.

tarangsachdev92 avatar tarangsachdev92 commented on June 17, 2024

ok.that's cool and aworking as expected for my requirement.Thank you 👍

from angular-tree-grid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.