Announcement

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

    ListGrid

    For the listGrid's fields, what do I do to make them have a fixed width and have a scroll bar that can scroll left and right when the width for each field is greater than the width of the grid altogether. Thanks.

    #2
    To make a field fixed width, just set field.width. The grid as a whole will scroll if the total field width is larger than the grid width.

    I'm not sure if you mean that you want each individual field to scroll independently. canFreezeFields:true partly offers this functionality, but if every single field needs to scroll independently, you'd need an HLayout of ListGrids or similar structure.

    Comment


      #3
      Thanks for the reply. Right now all the grid's headers come back as squeezed boxes. I want the ListGrid to show its, I guess I would call it, "autoFit" width. From there if the user wants to see the rest of the fields and its data that are not currently shown, they can scroll right or left. Thanks.

      Comment


        #4
        Originally posted by Isomorphic
        To make a field fixed width, just set field.width. The grid as a whole will scroll if the total field width is larger than the grid width.

        I'm not sure if you mean that you want each individual field to scroll independently. canFreezeFields:true partly offers this functionality, but if every single field needs to scroll independently, you'd need an HLayout of ListGrids or similar structure.
        Hi,

        Does the fix field width issue fixed ?
        I had similar problem ... setting the field width doesn't work.
        My code is below:

        Code:
                    ...
                    grid.setShowFilterEditor(true);
                    grid.setFilterOnKeypress(true);
                    grid.setCanDragSelect(true);
                    grid.setWidth("70%");
                    grid.setHeight100();
                    grid.setAutoFetchData(true);
                    grid.setAlternateRecordStyles(true);
        
                    grid.setDataSource(datasource);
        
                    ListGridField f[] = grid.getFields();
                    for (int i=0; i<f.length; ++i) {
                        f[i].setWidth(150);
                    }
                   ...
        The grid is a member of HLayout, and I use Firefox 3.x.
        I tried a lot of "autofit" related API ... no one work ... all fields are
        show and with "tiny" width which is hard to visible ...

        Regards
        KC

        Comment


          #5
          Hi,

          I think I found the problem ...
          To set the ListGrid field width, we need to explicitly create ListGridField for
          the ListGrid.
          If we only have DataSourceTextField without ListGridField, then we have
          no control over field width ....

          Could someone confirm this.

          Regards
          KC

          Comment


            #6
            Try this: call grid.setFields() after setting the dataSource. The fields are lazily created so trying to reference them during initialization doesn't work. However, calling setFields() will cause the dataSource fields to be mapped into the grid and then you can set an individual column width as desired.

            dave

            Comment


              #7
              Originally posted by davidj6
              Try this: call grid.setFields() after setting the dataSource. The fields are lazily created so trying to reference them during initialization doesn't work. However, calling setFields() will cause the dataSource fields to be mapped into the grid and then you can set an individual column width as desired.

              dave
              Hi Dave,

              Your suggestion is consistent with what I found ... I did setFields() inside
              Datasource before bind to ListGrid. It will be great if I can do this:

              grid.setFields(datasource.getFields())

              But there is not getFields() function for DataSource.
              Re-create a set of ListGridField and call grid.setFields(list_grid_files)
              solve the problem as I mentioned before ... but I don't like this
              solution because I need to prepare the list of fields twice (one for
              DataSource, the other for ListGridField).

              KC

              Comment


                #8
                I don't use SmartGWT but in the core library you can call grid.setFields() with no arguments and it pulls everything from the dataSource automatically.

                Comment


                  #9
                  Originally posted by davidj6
                  I don't use SmartGWT but in the core library you can call grid.setFields() with no arguments and it pulls everything from the dataSource automatically.
                  Hi David,

                  Cool, it works !!!
                  Just grid.setFields() will be enough. And all field width, attributes ...
                  could be completely determined inside DataSource (not in view).
                  Thanks, this is a great tip.

                  Regards,
                  KC

                  Comment


                    #10
                    Originally posted by kccheng
                    ...Just grid.setFields() will be enough....
                    Hi,

                    I'm sorry, I made a stupid mistake ...
                    The above conclusion is wrong. I still need ListGridField
                    to define field width. Simply set the field width inside DataSource
                    is not enough ... (at least in SmartGWT).

                    KC

                    Comment

                    Working...
                    X