Question:
Question:
we have,
newItem = CurrentContainer.cloneItem(existingItem);
is there a way to use it from a panel-container to clone an item from parent-container?
This could make my RollClock script probably 70% smaller.
]]>« 1950’s home (Previous Post)
< ![CDATA[
I am not sure of what you need, but cloneItem works on any item and you can get the parent container using Item.getParent(). From there you should be able to clone anything you need.
]]>
< ![CDATA[
wouldn’t the newly cloned item be in/partof the parent container?
]]>
< ![CDATA[
Yes, I realize only now that there is no “moveItem” function.
]]>
< ![CDATA[
pfew! I feared i missed something obvious 😉
]]>
< ![CDATA[
That can be fixed for the next update!
Container.moveItem(Item item, Container to_other_container)
]]>
< ![CDATA[
This is critical: The ID of an item depends on the container it is in. Will it change the ID or remain with an inconsistent ID?
]]>
< ![CDATA[
I guess it will change. The same as when changing it from lightning menu. I guess the function will return the new item. I don’t see any critical problem.
]]>
< ![CDATA[
Absolutely. References to the old item should be replaced with the item returned by the function.
]]>
< ![CDATA[
var tItemC = Tcont.cloneItem(tItem);
var newItem = Tcont.moveItem(tItemC, dc);
newItem.setCell(0, 0, 1, 1, true);
results in
cannot setCell of null
Is can see tItemC in container dc
am I using it wrong?
]]>
< ![CDATA[
I can confirm the bug.
The item is duplicated and moved to the container correctly. But the function returns null
]]>
< ![CDATA[
Yes, my bad, I just saw this.
]]>
< ![CDATA[
ok, i can wait. Thanks.
]]>
< ![CDATA[
Confirmed working in v12.5.1.
Thanks!
]]>
< ![CDATA[
eeeum… was I wrong expecting that the copied item kept its properties after a clone and move to a panel?
]]>
< ![CDATA[
If the properties are not specific they can change. I mean, the container have default properties, so if the item has the default setting it will have the default setting in the other container…and it can be different.
]]>
< ![CDATA[
are you sure? I will upload a screenshot, suggesting different.
]]>
< ![CDATA[
I didn’t tested, so maybe I’m wrong.
An screenshot will be fine 🙂
]]>