Announcement

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

    ListGrid expand and collapse groups not working

    I've got a rather large ListGrid that I default to using grouping. However, I'm unable to collapse the groups (regardless of the number of records). Any ideas? Here's the group-related code:

    Code:
    // To handle grouping with large numbers of records
    grid.setGroupByMaxRecords( 4000 );
    grid.setGroupStartOpen( "all" );
    // Group by status by default
    grid.setGroupByField( "status" );
    Several of my fields in the grid have setCanGroupBy( false ) set on them, if that makes a difference. I seem to remember this working before and I can't remember when it stopped working. Has anyone else run into this before?

    #2
    You may have adding event handlers that cancel events. Let us know if you figure out what you changed.

    Comment


      #3
      Will do. I'll look into the events thing, thanks for the tip.

      Comment


        #4
        Well, it seems to be related to adding a CellClickHandler to the grid. If I remove this, it works fine. However, I'm not canceling events inside of the CellClickHandler. Here is the code (with some lines removed for brevity, and for reference my class extends ListGrid):

        Code:
                addCellClickHandler( new CellClickHandler()
                {
                    public void onCellClick( CellClickEvent event )
                    {
                        // Retrieve information about the record clicked on
                        final ListGridRecord record = event.getRecord();                
                        final int engineId = record.getAttributeAsInt( EngineDataSource.ENGINE_ID );
                        
                        String fieldName = getFieldName( event.getColNum() );
                        
                        if( fieldName.equals( "upload" ) )
                        {
                            // Do something
                        }
                        else if( fieldName.equals( "view" ) )
                        {
                            // Do something else
                        }
                    }
                } );
        Any ideas?

        Comment


          #5
          Are you on the latest from SVN? Several events were reworked recently so that they don't override the built-in behavior unless you explicitly cancel() the event.

          Comment


            #6
            Isomorphic,

            I'm pulling the latest SNAPSHOT from maven. I don't pull from svn. Is the latest maven SNAPSHOT built from the latest svn?

            Thanks for your help. SmartGWT has been great to work with and develop in and you all have been very good with support.

            Comment


              #7
              timclymer,
              Please read this post on how to ask for help. When you say something is not working, you need to provide a standalone testcase. Posting snippets doesn't help as we have no idea what the rest of your code is doing.

              I modified the Dynamic Grouping sample and added a CellClickHandler and it works just fine.

              So please post a standalone test case when you say something is not working. The test case code needs to be complete and have an onModuleLoad() that we can copy-paste and run locally. It will save our time as well as help get to the bottom of the problem faster.

              Comment


                #8
                smartgwt.dev,

                I am sorry if it came across that I was implying that SmartGWT wasn't working. I was wondering what _I_ might be doing incorrectly before trying to point to a bug in SmartGWT.

                To update, I think the problem stems from the fact that I'm clicking on a group header, and when I attempt to retrieve its values via getAttribute*, I get NullPointerExceptions (which caused the event cancellation behavior that Isomorphic correctly pointed to). I've headed this off by calling record.getSingleCellValue() before calling getAttribute. If this call returns a non-null, then I know that the record is a header. Is there another method or way of going about this that would provide the same functionality? I've tried printing our getIsSeparator() but that always seems to be false for group headers.

                To be clear, this is what I'm doing as a check:

                Code:
                            public void onCellClick( CellClickEvent event )
                            {
                                // Retrieve information about the record clicked on
                                final ListGridRecord record = event.getRecord();
                
                                // Only process this record if it's a real record (and not a group header)
                                // Group headers will have only a single cell value
                                if( record.getSingleCellValue() == null )
                                {
                                    final int engineId = record.getAttributeAsInt( EngineDataSource.ENGINE_ID );

                Comment

                Working...
                X