Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Disable(gray out) checkboxes in TreeGrid

    Hi all,

    Is it possible to disable(gray out) only checkboxes in TreeGrid? I've tried to use setRecordCanSelectProperty() --> canSelect (checkbox dissapear).

    #2
    Any update on this? We're looking to do the same thing in our app. Thanks!

    Comment


      #3
      This has been addressed internally and should be available in subsequent official releases and nightly builds. A property has been added to TreeGrid called 'showDisabledSelectionCheckbox' which, if set, will display a disabled
      checkbox icon instead of a blank space.

      Comment


        #4
        Awesome! Is there any way to patch this feature into 2.4? Our environment prohibits us from using nightly (or even updated releases).

        Comment


          #5
          Sorry, this is an enhancement that we just did as a freebee rather than a fix as such, so it's not something we'd create a patch for.

          How do you mean your environment "prohibits" the use of nightlies? It seems like you should be able to use nightlies for testing and development with the aim of shipping on a final version. This will also help us ensure we don't have any regressions that affect you when we ship the final version.

          Comment


            #6
            Thanks for your reply.

            We're shipping with 2.4 in our final version. Due to security concerns, we're stuck with version 2.4. However, patches are allowed for critical features.

            Comment


              #7
              Hello,

              setShowDisabledSelectionCheckbox doesn't look that nice when you don't have selection behavior on folders, but on children only.

              See attached screenshot - is the 3rd layout not possible to achieve?


              In addition, business requirements will say that some children are actually mutual exclusive with another child. So selecting a whole folder which auto selects the children isn't possible to do: reason to not have the checkbox on a folder.

              I might have to come back on this topic, because that means that some children can show a checkbox, and mutual exclusive children should show a radio button (a mix is possible in the same folder). _I've added a screenshot to explain a bit better_.

              So when I'm implementing that, I will need to overrule the built in checkbox layout myself anyway. Is there already something like that for that TreeGrid auto added checkbox column? Because it would probably be the excellent place to decide on "isFolder? don't show extra column : show checkbox/radio button column".


              thanks
              Attached Files
              Last edited by levi; 22 Apr 2012, 02:12.

              Comment


                #8
                TreeGrid.getExtraIcon() and related settings allow you to add an additional icon where you see the checkbox selection icon.

                Comment


                  #9
                  Aha, cool, thanks!

                  Comment


                    #10
                    I'm not getting the extra icon to do anything (2nd screenshot in previous post). What am I doing wrong here?
                    I also wonder if I will have to implement things myself to handle the mouse clicks to change the icon on that event?



                    Tried with SC_SNAPSHOT-2012-02-01_v8.3d/Pro Deployment (built 2012-02-01)
                    and SNAPSHOT_v8.3d_2012-06-23/Pro Deployment (built 2012-06-23)

                    Code:
                    private class MyTreeGrid extends TreeGrid {
                    	
                    	public MyTreeGrid() {
                    		
                    	}
                    	
                    	@Override
                    	public String getExtraIcon(TreeNode node) {
                    		//never called?
                    		return "[SKINIMG]/actions/approve.png";
                    	}
                    }
                    
                    public Canvas getViewPanel() {
                    	
                    	MyTreeGrid grid = new MyTreeGrid();
                    	grid.setExtraIconGap(20); //no impact either
                    	
                    	String fieldName1 = "id";
                    	String fieldName2 = "name";
                    	String parentField = "parent";
                    	ListGridField field1 = new ListGridField(fieldName1);
                    	ListGridField field2 = new ListGridField(fieldName2);
                    	ListGridField field3 = new ListGridField(parentField);
                    	grid.setFields(field2, field1, field3);
                    	
                    	TreeNode rootNode = new TreeNode();
                    	int rootNodeID = 0;
                    	rootNode.setAttribute(fieldName1, rootNodeID);
                    	rootNode.setAttribute(fieldName2, "root");
                    
                    	TreeNode [] records = new TreeNode[5];
                    	for (int i=0; i<records.length; i++) {
                    		records[i] = new TreeNode();
                    		records[i].setAttribute(fieldName1, (i+1));
                    		records[i].setAttribute(fieldName2, "oho" + (i+1));
                    		records[i].setAttribute(parentField, i);
                    	}
                    	
                    	Tree dataTree = new Tree();
                    	dataTree.setModelType(TreeModelType.PARENT);
                    	dataTree.setIdField(fieldName1);
                    	dataTree.setParentIdField(parentField);
                    	dataTree.setNameProperty(fieldName2);
                    	dataTree.setAutoOpenRoot(true);
                    	dataTree.setReportCollisions(false);
                    	dataTree.setShowRoot(false);
                    	dataTree.setAutoOpenRoot(true);
                    	dataTree.setRoot(rootNode);
                    	dataTree.setData(records);
                    	grid.setData(dataTree);
                    	
                    	VLayout layout = new VLayout();
                    	layout.setWidth100();
                    	layout.setMembers(grid);
                    	return layout;
                    }

                    Comment


                      #11
                      Could you clarify "not getting the extra icon to do anything"? What did you expect it to do and/or what is wrong with its appearance?

                      Comment


                        #12
                        I expected it to see it somewhere.
                        I don't see anything, as shown with the repro case provided.
                        I also set a wide gap, that also doesn't have any impact.

                        In attached screenshot:
                        1) on top: the same code with grid.setSelectionAppearance(SelectionAppearance.CHECKBOX);
                        2) bottom: the same code without this SelectionAppearance setting. I expected the approve.png (== the extra icon) to be shown where the checkbox is.
                        Attached Files

                        Comment


                          #13
                          It's expected and doc'd that getExtraIcon() does not apply when selectionAppearance is "checkbox".

                          We'll check on the report that it's not working when selectionAppearance is *not* checkbox, however, just to clarify, in order to set your own icons you will need to basically implement your own selection behavior entirely. That seems to be what you want anyway (radio selection for some folders) but we wanted to make sure that was understood.

                          Comment


                            #14
                            Yep, the checkbox appearance was to show that those checkboxes were working, and then the gap also did something.

                            I already expected that I would have to do things myself,
                            as I got very weird behavior with cascading, partial selection and then selecting a node from code.
                            It seems that from code (e.g. initial data set on the tree), there is no way to mark a node as partially selected, but that the tree works out the select state of a folder on its own. So I need to make sure that only children have the selected property when cascading.
                            Is that a correct assumption of me?

                            I am on a build of Feb 2012 though and saw some other posts where debugs have been done in that area, so I'll pick this up later.



                            It would be neat though if SmartGWT had the "mutual exclusive selection" on trees built in ;)
                            sample:
                            http://delphi.about.com/od/vclusing/l/aa092104a.htm

                            Comment


                              #15
                              Right, partial selection is a computed state so it would not make sense to set it directly. To partially select a node, select a child.

                              Comment

                              Working...
                              X