Opened 11 years ago
Closed 11 years ago
#7710 closed enhancement (fixed)
[patch] [cla] Tree: Add a "getIconStyle" method
Reported by: | rdunklau | Owned by: | bill |
---|---|---|---|
Priority: | high | Milestone: | 1.3 |
Component: | Dijit | Version: | 1.1.1 |
Keywords: | tree style icon | Cc: | |
Blocked By: | Blocking: |
Description
It would be nice to have a "getIconStyle" method , similar to the "getIconClass" one. That would allow specific/dynamics tree icons. A simple example where it would be useful : if you want to display a tree which nodes represents music albums, you don't want to create a css class per node. Moreover, it would be consistent with what already exists for the grid widget.
Attachments (2)
Change History (9)
comment:1 follow-up: 2 Changed 11 years ago by
Milestone: | tbd → 1.3 |
---|---|
Owner: | set to bill |
comment:2 Changed 11 years ago by
Replying to bill:
Sure, I guess that makes sense. It would typically return something like "background-image: url(album1.jpg)" ?
Yes, that's exactly how i imagined it. By the way, it should also prosose a "getLabelStyle" for the same purpose.
comment:3 Changed 11 years ago by
I implemented it, the same way onStyleRow was implemented for the grid, since i did not know how to parse a CSS declaration. So i used the very same _setStyleText that was used in grid RowManager?.
Is there a way to use dojo.style instead ?
Here comes a patch (WARNING : it comes with the modification i posted on #7717), along with a test case.
Changed 11 years ago by
Attachment: | TreeStyles.patch added |
---|
comment:4 Changed 11 years ago by
Summary: | [Tree] Add a "getIconStyle" method → [patch] [cla] Tree: Add a "getIconStyle" method |
---|
Hi rdunklau, thanks for the patch!
The way to use dojo.style() to "set the whole style" is to pass it an object, ex:
dojo.style("thinger", { "opacity": 0.5, "border": "3px solid black", "height": 300 });
I wonder if having getIconStyle() return an Object might be a better API than returning a string?
Also, for the double-click handler is there a reason to have the onDblClick open option on the Tree. I don't want to add options to Tree unless they are really useful.
comment:5 Changed 11 years ago by
I think it may be useful if you want to use the drag'n'drop feature : a simple click can not be used to expand the node, but developers may want to provide another option to perform node expanding. I'm no ergonomy expert, but this option could be useful. As for the getIconStyle method, the implementation was inspired by the grid onStyleRow method.
comment:6 Changed 11 years ago by
Status: | new → assigned |
---|
I see.
I thought of a reason to return a dojo.style() parameter Object... so that dojo.style can do normalization like for setting opacity.
Anyway, I will modify the patch slightly to work with objects and then check it in.
comment:7 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Checked in by [15693], thanks for the patch!
Sure, I guess that makes sense. It would typically return something like "background-image: url(album1.jpg)" ?