Announcement

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

    #16
    Yes 100% sure, it is simply making a call to the javascript method that exists in ListGrid.js but needs to first get the ListGrid object which contains the method. What is your exception your getting? Here is the code, make sure you have the same. *(of course had to make my own records)
    Code:
    public class MultiSelectCriteiraGrid extends ListGrid
    {
        public static final String FIELD_ID = "id";
    
        public static final String FIELD_PID = "pid";
    
        public static final String FIELD_VALUE = "value";
    
        public MultiSelectCriteiraGrid(final String title)
        {
            setWidth(220);
            setShowAllRecords(true);
            setAlternateRecordStyles(true);
            setLeaveScrollbarGap(false);
            setSelectionType(SelectionStyle.SIMPLE);
            setSelectionAppearance(SelectionAppearance.CHECKBOX);
            setCanSelectAll(true);
            final ListGridField fieldId = new ListGridField(FIELD_ID);
            fieldId.setHidden(true);
            final ListGridField parentId = new ListGridField(FIELD_PID);
            parentId.setHidden(true);
            final ListGridField fieldName = new ListGridField(FIELD_VALUE, title);
            fieldName.setCanSort(false);
            fieldName.setCanGroupBy(false);
            fieldName.setCanHide(false);
            fieldName.setCanDragResize(false);
            setFields(fieldId, parentId, fieldName);
        }
    
        public void populateData()
        {
            ListGridRecord[] d = new ListGridRecord[3];
            for (int i = 0; i < 3; i++) {
            	d[i] = new ListGridRecord();
            	d[i].setAttribute("id", Random.nextInt());
            	d[i].setAttribute("pid", Random.nextInt());
            }
        	setData(d);
        }
        
        public native void _setCheckboxHeaderState(boolean state) /*-{
        	var self = this.@com.smartgwt.client.widgets.BaseWidget::getOrCreateJsObj()();
        	self._setCheckboxHeaderState(state);
      	}-*/;
    }
    
     public void onModuleLoad() {  
    	 final MultiSelectCriteiraGrid g = new MultiSelectCriteiraGrid("TITLE");
    	 g.populateData();
    	 g.addDrawHandler(new DrawHandler() {
    		@Override
    		public void onDraw(DrawEvent event) {
    			g.selectAllRecords();
    			g._setCheckboxHeaderState(true);
    		}
    	 });
    	 g.draw();
     }

    Comment


      #17
      It still didn't work. After setting the data i called the draw method explicitly but still it didn't work. No javascript error/warning.
      I tried one more thing, I remove the call to _setCheckboxHeaderState to check if selectAllRecords() is working fine and I noticed that column checkbox is checked if the list contains one and only one item though items are always checked.

      I am thinking to implement this functionality of my own by having first record as All and implement the rest of things. i will set the setCanSelectAll(false) to hide the column checkbox.

      thanks a lot for your help. I will still keep trying if you reply to this thread but I think I have already bothered you a lot :)

      Comment


        #18
        Does your onModuleLoad look like the one I posted?

        Comment


          #19
          No it is not exactly like that as in my case these grids are part of a form which is one part of the whole module. I show/hide this form on click of some buttons. But i think over all things should work. e.g. selectAllRecords() always works no matter when and where I call after setting the data.

          Comment


            #20
            when i add the checkbox header state method.it will throw javascript exception.
            can you send me the code.
            Last edited by praveen.reddy; 3 Aug 2010, 01:52.

            Comment


              #21
              The reason you are getting a javascript exception is because the call to
              Code:
              _setCheckboxHeaderState(state)
              is obfuscated.

              If you change your inherits from
              Code:
              <inherits name="com.smartgwt.SmartGwt" />
              to
              Code:
              <inherits name="com.smartgwt.debug.SmartGwtDebug" />
              then the workaround will work. Not a good solution in my opinion.

              Comment


                #22
                I even tried out the showcase example of listgrid checkbox. Even if i do countryGrid.selectAllRecords(), the header checkbox is not selected. What might be the problem. I am using the latest build of smartgwt.

                Comment


                  #23
                  You need to extend the ListGrid class. This is what I did:

                  Code:
                  public class USPListGrid extends ListGrid {
                  
                      public USPListGrid() {
                          super();
                      }
                  
                      public USPListGrid(final JavaScriptObject jsObj) {
                          super(jsObj);
                      }
                  
                      public final native void selectAll() /*-{
                          var self = this.@com.mjnservices.webguard.smartgwt.client.USPListGrid::getOrCreateJsObj()();
                          self.selectAllRecords();
                          self._setCheckboxHeaderState(true);
                      }-*/;
                  }
                  You need to also make sure you inherit the SmartGWTDebug:

                  Code:
                  <inherits name="com.smartgwt.debug.SmartGwtDebug" />

                  Comment


                    #24
                    This bug is already marked fixed. If anyone is experiencing this with a nightly build, please let us know and post a test case.

                    Note that it is expected that if data is not completely loaded, only loaded records become selected and the checkbox should not appear checked.

                    Comment


                      #25
                      Hi Isomorphic,

                      Is there any way I can get control to this checkbox (select all) in list grid header. I really can not take the nightly build as We are running this code in production. There are couple of issues as mentioned in this thread. One strange issue i found, this checkbox does not work if the grid has one record. and by default it's checked even though record is not selected.

                      If you can give me some idea to get access to this checkbox, i can write some code.

                      Thanks, Amit

                      Comment

                      Working...
                      X