I have a deep tree and for user it’s difficult to distinguish the levels. Is it possible to have custom css-classes for each level? For example firstlike h1 and bold, second bold …
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I find the question interesting, but I think that one can better use individual icons for the tree nodes. If you do need to set CSS style per row I can you forward to the answer and this one. You should just change the test criteria in the demos to test the content of the hidden
levelcolumn.So I created the demo which demonstrate how you can set individual icons per node level:
First of all I should mention, that TreeGrid supports individual icons for leafs out-of-the-box. You can just add
iconproperty to the posted data. The value of the property should be the CSS class which will be added to thedivwhich represent the icon. For exampleicon: "ui-icon-star". The standard class for the icon is “ui-icon-radio-off”. Additionally the div receive the classes “ui-icon tree-leaf treeclick”. So if you find the icon which you need in the standard jQuery UI icons the changing if the icon of the leaf will be very easy.Non-leaf tree nodes have two icons: one in the collapsed form and another in the expanding form. There are no simple way to change the icons per jqGrid configuration, but you can implement the requirement by writing an additional JavaScript code inside of
loadCompleteand with respect of chaining (overwriting or subclassing) ofexpandNodeandcollapseNodemethod like I suggested here.In the demo I just changed the icons of the top-level tree nodes. In the same way you can change icons on any other level. Below you find the most important parts of the code from my demo:
UPDATED: I thought a little more about the problem of tree icons and modified the code to the new demo.
I decided that it would be more practicable to be able to define icons of the tree node exactly like for the leafs. Because one need to specify two icons one can separate the classes for collapsed and expanded icons by comma. For example:
icon: "ui-icon-carat-1-e,ui-icon-carat-1-s". The code can be rewritten to the following:UPDATED: I posted the feature request and the pull request which add the described above functionality to TreeGrid.