0

render inserted treeitem in load-on-demand tree

asked 2014-07-02 18:39:08 +0800

robertkaren gravatar image robertkaren
77 7

I have a load-on-demand MVC tree with my own model and renderer. the renderer is below. I want to add a new treeitem to top of tree? I added it to the model but it isn't showing up in tree (there is no exception) I tried this after adding to model but no response. Maybe problem is the path. I am adding to model using path "0" for top node. do I have to increment first member of all of the other paths in the model?

int[] intArr = {0}; 
tree.renderItemByPath(intArr);

Thanks for any help. here is my renderer, if that helps:

    public class ProjectsTreeRenderer implements TreeitemRenderer {
@Override
    public void render(Treeitem treeItem, Object data, int i) throws Exception {
        ArrayList ar = (ArrayList) data;
        Treecell title = new Treecell(ar.get(1).toString());
        try {
            if (isFolder(ar)) {
                title.setImage("/img/folder.jpg");
                title.setSclass("titleClass");
            }
        } catch (NumberFormatException err) {
                  // ...
        } catch (Exception err) {
                  // ...
        }
        Treecell created = new Treecell((String) ar.get(5));
        Treecell modified = new Treecell((String) ar.get(6));
        Treecell desc = new Treecell((String) ar.get(7));
        Treecell study = new Treecell((String) ar.get(4));
        String cssStyleCentered = "text-align:center";
        created.setStyle(cssStyleCentered);
        modified.setStyle(cssStyleCentered);
        study.setStyle(cssStyleCentered);
        String path = (String) ar.get(3);
        Treerow treeRow = null;
            //
        if (treeItem.getTreerow() == null) {
                treeRow = new Treerow();
                treeRow.setParent(treeItem);
                //treeItem.appendChild(treeRow);
        } else {
                treeRow = treeItem.getTreerow();
                treeRow.getChildren().clear();
        }
        title.setParent(treeRow);
        study.setParent(treeRow);
        created.setParent(treeRow);
        modified.setParent(treeRow);
        desc.setParent(treeRow);
        treeItem.setOpen(false);
        addListenerForClick(treeRow);
}
delete flag offensive retag edit
Be the first one to answer this question!
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2014-07-02 18:39:08 +0800

Seen: 8 times

Last updated: Jul 02 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More