GXT 3.1:如何取消选择树形网格中的选定行?

时间:2015-01-12 21:16:50

标签: java gxt

是否有默认方式允许用户取消选择所选行? 如果没有,我想在另一次点击中取消选择该行。我怎样才能实现它?

在下面的文字中,我附上了我的树格栅的代码片段

    // ----------------------  set up columns ------------------------ \\
    // set up name column
    ColumnConfig<ProductMapping, String> cc1 = new ColumnConfig<ProductMapping, String>(new ValueProvider<ProductMapping, String>(){
        @Override
        public String getValue(ProductMapping object) {
            return object.getName();
        }

        @Override
        public void setValue(ProductMapping object, String value) {
            object.setName(value); 
        }

        @Override
        public String getPath() {
          return "name";
        }
    });
    cc1.setWidth(200);
    cc1.setHeader("Name");

    // setup solution column
    ColumnConfig<ProductMapping, String> cc2 = new ColumnConfig<ProductMapping, String>(new ValueProvider<ProductMapping, String>() {
        @Override
        public String getValue(ProductMapping object) {
            return object.getSolution();
        }

        @Override
        public void setValue(ProductMapping object, String value) {
            object.setSolution(value); 
        }

        @Override
        public String getPath() {
          return "solution";
        }
    });
    cc2.setHeader("Solution");
    cc2.setWidth(200);

    // setup condition column
    ColumnConfig<ProductMapping, String> cc3 = new ColumnConfig<ProductMapping, String>(new ValueProvider<ProductMapping, String>() {
        @Override
        public String getValue(ProductMapping object) {
            return object.getCondition();
        }

        @Override
        public void setValue(ProductMapping object, String value) {
            object.setCondition(value); 
        }

        @Override
        public String getPath() {
          return "condition";
        }
    });
    cc3.setHeader("Condition");
    cc3.setWidth(200);

    // create column model
    List<ColumnConfig<ProductMapping,?>> ccl = new LinkedList<ColumnConfig<ProductMapping,?>>(); 
    ccl.add( cc1);
    ccl.add( cc2);
    ccl.add( cc3);
    ColumnModel<ProductMapping> cm = new ColumnModel<ProductMapping>(ccl);

    // Create the tree grid using the store, column model and column config for the tree column
    tg = new TreeGrid<ProductMapping>(treeStore, cm, ccl.get(0));
   // tg.getSelectionModel().get
    tg.addRowClickHandler(new RowClickEvent.RowClickHandler(){

        @Override
        public void onRowClick(RowClickEvent event) {
            tgRowClicked(event);
        }

    });

0 个答案:

没有答案