Question

I've got a cardboard, and I get a list of the cards displayed by calling: cardboard.getCards()

I'd like to update the color of some of those cards, so I iterate through the cards, and when I find one I want to update I do the following:

    var record   = card.getRecord();
    var newColor = '#ff0000';

    record.set('DisplayColor', newColor);

...but it does not change the card. However, if I call the same code as a result of a beforecarddroppedsave event, the color changes immediately.

Through a bit of experimenting, I have a solution if I follow the record.set() line with this:

    this.outstandingUpdates++;
    record.save({callback: function() {
        if (--this.outstandingUpdates === 0) {
            this.cardboard.refresh();
        }
    }, scope: this});

...but its kind of ugly in that you see the board refresh, and it seems like there should be a better way to do this so that it acts like when called from the beforecarddroppedsave event (and if not that, just having one callback instead of having to count the updates).

Is there a better, less ugly way to do this that does not require a refresh of the whole cardboard?

Was it helpful?

Solution

The cards have a reRender method (it's private- not sure why- you'll have to show private methods to see it in the docs). This is how all the Rally apps refresh individual cards.

So the simplified code using reRender would be:

record.set('DisplayColor', color);
record.save({callback: function() { card.reRender(); });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top