How to cancel selection for TreePanel(GXT)

Today, I want to add a function to cancel selection of a tree item in tree panel.

I already implementated this before, but I can’t remember how to do this.

So I search the original code and save here, so next time, I can find it from here.

 

treePanel.getSelectionModel().addListener(Events.BeforeSelect, new Listener<SelectionEvent<ModelData>>() {

            @Override
            public void handleEvent(SelectionEvent<ModelData> be) {
                // Get the model data
                ModelData model = be.getModel();

               // Check the model data and if want to cancel selection, then set canceled value
                if (model.get("disableSelect") != null) {
                    be.setCancelled(true);
                }
            }
        });

posted on 2014-03-01 17:01  liwp_Stephen  阅读(201)  评论(0编辑  收藏  举报

导航