Coder Social home page Coder Social logo

Comments (3)

akoenig avatar akoenig commented on May 26, 2024

I have not tested it yet. The deckgrid will be rendered again if the object count of the source collection has changed. Any other change reflects without a re-rendering. So my guess is that it will work. Let me know if you've tried it :)

from angular-deckgrid.

brianweiner avatar brianweiner commented on May 26, 2024

Am I wrong in thinking that this function won't trigger if the array order changes?

  Deckgrid.prototype.$$onModelChange = function $$onModelChange (oldModel, newModel) {
        var self = this;

        if (oldModel.length !== newModel.length) {
            self.$$createColumns();
        }
    };

Have you considered using angular.equals instead?

  if (!angular.equals(oldModel, newModel){
    self.$$createColumns();
  }

It seems to work well for me

from angular-deckgrid.

akoenig avatar akoenig commented on May 26, 2024

Well, it's complicated. :) Consider the scenario that you have a lot of objects in your deckgrid (which was my use case while developing the directive). When using the angular.equals method, changing one property of an object in the source collection means triggering the whole grid rendering again. An use case that works fine for small collections or not many object property changes.

One option could be to integrate a "strict mode", like:

deckgrid-strict="true" => !angular.equals(oldModel, newModel)

deckgrid-strict="false" (default) => oldModel.length !== newModel.length

Another option would be to use angular.extend within your code (if you have a source collection in which every object has the same property structure). This is useful if you want to switch positions without losing references.

Let me know what you think.

from angular-deckgrid.

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.