How do I use the custom icons for individual nodes in a tree grid.
By default, just set the icon property on the node.
If that property has meaning in your dataSet, you can modify TreeGrid.customIconProperty to something other than “icon”, and set that property on the node instead.
Thanks for the prompt reply.
Sorry I didnt get you. Do you have any example showing the same ?
Hi
The node titles example in the feature explorer can be easily modified to demonstrate this concept:
If you look at the raw data for this tree in the employeeData.js tab, it contains each node as a raw javascript object. Changing the first such object so it has a specified icon property will make a custom icon show up for that node:
{
EmployeeId:"4", ReportsTo:"1", Name:"Charles Madigen", Job:"Chief Operating Officer",
Phone:"x10962", Email:"cmadigan@server.com", OrgUnit:"Management", Salary:26200.00,
Gender:"male", MaritalStatus:"married", EmployeeType:"full time", EmployeeStatus:"active",
isOpen: true, icon:"foo.gif"
},
If you then view the example, rather than displaying the standard ‘folderIcon’ for the node in question, it will attempt to load ‘foo.gif’.
(foo.gif isn’t present of course, so you’d get a broken image in this case, but you get the idea).
Ok - now say in your application “icon” has a specific meaning for nodes - in this case you’d want to use a different property to specify the icon to display in the tree. You can do this with the customIconProperty attribute of the TreeGrid. So your treeGrid definition would contain this:
isc.TreeGrid.create({
ID: "employeeTree",
width: 500,
height: 400,
customIconProperty:"treeGridIcon",
... other props
});
and in your data, instead of icon:“foo.gif” you’d set treeGridIcon:“foo.gif”
Note also that the icon image’s URL uses the standard getImgURL(), so by default will be prepended with the appImgDir for the Page / widget in question.
Perfect,
Thanks a lot. I got it now.. Let me explain my scenario. Say I have 10 rows of data of which one row uses custom Icon (as folder Icon).
So for this, when we specify “customIconProperty” in the treeGrid definition, we have to specify the icons in all the rows in rawdata…
So for the above situation, I have to replicate the same Icon value for all the rows except that one row which uses the different image..
Is there any other way to get this done ? Or am I getting it wrong.
No need to set the icon property for every node - just for the one node that shows a custom icon.
The other nodes will all show the standard folderIcon or nodeIcon