Open stefanofornari opened 10 years ago
What about Timeline.changeItem(index, itemData [, preventRender])
?
Hi Jos, I had a look at that code, but it seemed behind the current implementation. I have two main concerns:
Maybe it should use createItem instead, but I am not sure. It does not seem to be very used.
Thoughts?
Ste
On Wed, Apr 16, 2014 at 2:05 PM, Jos de Jong notifications@github.comwrote:
What about Timeline.changeItem(index, itemData [, preventRender])?
— Reply to this email directly or view it on GitHubhttps://github.com/almende/chap-links-library/issues/280#issuecomment-40590947 .
You have functions createItem
, changeItem
, and deleteItem
. The function changeItem
indeed creates a new item internally, but it merges the old properties with the newly provided ones, so in the end you have an updated item. I'm sure this can be optimized.
ok, thanks. I'll have a deeper look into it.
Ste
On Wed, Apr 16, 2014 at 2:30 PM, Jos de Jong notifications@github.comwrote:
You have functions createItem, changeItem, and deleteItem. The function changeItem indeed creates a new item internally, but it merges the old properties with the newly provided ones, so in the end you have an updated item. I'm sure this can be optimized.
— Reply to this email directly or view it on GitHubhttps://github.com/almende/chap-links-library/issues/280#issuecomment-40592784 .
Re-looking into it, I remember better why it does not work :)
links.Timeline.prototype.changeItem = function (index, itemData, preventRender)
works with the raw data, but what instead I need is a way to change an item already created (an instance of Item, not the data[]).
Thoughts?
Ste
On Wed, Apr 16, 2014 at 4:33 PM, Stefano Fornari stefano.fornari@gmail.comwrote:
ok, thanks. I'll have a deeper look into it.
Ste
On Wed, Apr 16, 2014 at 2:30 PM, Jos de Jong notifications@github.comwrote:
You have functions createItem, changeItem, and deleteItem. The function changeItem indeed creates a new item internally, but it merges the old properties with the newly provided ones, so in the end you have an updated item. I'm sure this can be optimized.
— Reply to this email directly or view it on GitHubhttps://github.com/almende/chap-links-library/issues/280#issuecomment-40592784 .
The Timeline doesn't have an API to manipulate (internal) Items, so if you really need that I guess the Timeline needs some new methods for that.
What is exactly your use case, needing to manipulate an instantiated Item
rather than the data?
Hi Jos, maybe you are right. I guess I am looking for a more direct way to update an item. currently in order to change the start date of an item I edit and see the change as soon as I save it, I have to do something like:
var i = 0; data = timeline.getData(); fo (var i=0; i<data.length; ++i) { if (data[i].id == fields.id) { timeline.updateData(i, data[i]); break; } } timeline.render();
It is not very elegant.
timeline.changeItem(i, data[i], false) does not work.
I am not sure there is an easy solution...
Ste
On Tue, Apr 22, 2014 at 9:37 AM, Jos de Jong notifications@github.comwrote:
The Timeline doesn't have an API to manipulate (internal) Items, so if you really need that I guess the Timeline needs some new methods for that.
What is exactly your use case, needing to manipulate an instantiated Itemrather than the data?
— Reply to this email directly or view it on GitHubhttps://github.com/almende/chap-links-library/issues/280#issuecomment-41011685 .
If timeline.changeItem(i, data[i], false)
doesn't work, isn't that a bug then which should be fixed?
:) If it is a bug yes! I was not sure, I thought I was missing something. maybe we should then keep this issue open as bug?
Ste
On Fri, Apr 25, 2014 at 9:34 AM, Jos de Jong notifications@github.comwrote:
If timeline.changeItem(i, data[i], false) doesn't work, isn't that a bug then which should be fixed?
— Reply to this email directly or view it on GitHubhttps://github.com/almende/chap-links-library/issues/280#issuecomment-41366198 .
Sorry for the late reply.
I tried timeline.changeItem
, and that seems to work fine. Note that this function expects a JavaScript object with (optional) fields start
, end
, content
, etc. It doesn't support a Google DataTable as input. And of course if you set the third parameter preventRender
false, you will have to do a repaint yourself afterwards. Can any of this be the problem?
From the docs:
changeItem(index, properties)
Change properties of an existing item in the Timeline. index (Number) is the index of the item. The provided parameter properties is an Object, and can contain parameters start (Date), end (Date), content (String), group (String), className (String), and editable (Boolean).
Hi, what's the best way of repainting a single item after changing its start date?
thanks in advance, Ste