Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the POS actually mean in the Trello API

I'm using dillenmeisters Trello.Net API Wrapper, and on each Card it has a POS attribute. I thought that was for position in the list that it was in, but the numbers seem arbitrary, ranging from 4 to 5 digit numbers. Is there anyway to make sense of these enough to "place" a new Card between 2 others that already exist in the list?

like image 324
B-Wint Avatar asked Jan 21 '13 20:01

B-Wint


People also ask

What can you do with Trello API?

The Trello API offers the ability to search all the actions, boards, cards, members, and organizations. While you can't control which fields you want to search, you can specify which fields you want your search to return.

Is there a Trello API?

Trello provides a simple RESTful web API where each type of resource (e.g. a card, a board, or a member) has a URI that you can interact with. The Trello API documentation is available at https://developer.atlassian.com/cloud/trello.


1 Answers

Edit:

Available in version 0.5.9-beta1 of Trello.NET (on NuGet):

// Ways to set the position of a card
trello.Cards.ChangePos(card, 1234)
trello.Cards.ChangePos(card, Position.Top)
trello.Cards.ChangePos(card, Position.Bottom)

I haven't dug deeply into how pos works, but I think it's a sort order. If you want to move a card between two other cards, you could get the position of those two cards and add their Pos together and divide by two.

For example, if you want to insert Card C between Card A and Card B:

  1. Card A - Pos 16
  2. Card B - Pos 32
  3. Card C - Pos 64

(16 + 32) / 2 = 24. Set Card C Pos to 24.

  1. Card A - Pos 16
  2. Card C - Pos 24
  3. Card B - Pos 32

I think they do this so that they only have to update ONE Pos when a card is moved (instead of the Pos of all cards after it which would be necessary if they used a sequential Pos with no gaps).

like image 58
dillenmeister Avatar answered Sep 17 '22 15:09

dillenmeister