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)

test_Tree_getStyles.html (2.5 KB) - added by rdunklau 11 years ago.
Test Case
TreeStyles.patch (3.3 KB) - added by rdunklau 11 years ago.
Patch including change for #7710 and #7717

Download all attachments as: .zip

Change History (9)

comment:1 Changed 11 years ago by bill

Milestone: tbd1.3
Owner: set to bill

Sure, I guess that makes sense. It would typically return something like "background-image: url(album1.jpg)" ?

comment:2 in reply to:  1 Changed 11 years ago by rdunklau

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 rdunklau

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 rdunklau

Attachment: test_Tree_getStyles.html added

Test Case

Changed 11 years ago by rdunklau

Attachment: TreeStyles.patch added

Patch including change for #7710 and #7717

comment:4 Changed 11 years ago by bill

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 rdunklau

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 bill

Status: newassigned

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 bill

Resolution: fixed
Status: assignedclosed

Checked in by [15693], thanks for the patch!

Note: See TracTickets for help on using tickets.