Announcement

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

    ListGrid -> Implicit column width by size of the values

    Dear SmartGWT users,
    I have ListGrid with two columns. First column contains name and second column contains description. Name is usually one word and description is usually one or more sentences. If I do not specify width of the columns explicitly each column occupy 50% of available space. From my point of view it will be very nice if width of the column name will be set by size of the values it contains. Then width of the column name with one word will be less than width of the column description with sentences. There will be less empty space. Is possible to implement this funcionality by current API?

    Best regards,

    Ales

    #2
    See setAutoFitData()

    Comment


      #3
      Isomorphic thanks for your reply but method ListGrid.setAutoFitData() does not help me. After setting this property columns still occupy 50% of available space for ListGrid.

      Best regards,

      Ales

      Comment


        #4
        That's not what it does in samples. Take a second look.

        Comment


          #5
          I do apologize but I could not find any sample with functionality I need. :-(

          I have this sample code:
          Code:
          public void onModuleLoad() {
          	DataClass dc = new DataClass();
          	dc.setAttribute("name", "name");
          	dc.setAttribute("description", "very very very very very very very very long description");
          
          	DataSource ds = new DataSource();
          	ds.setFields(new DataSourceIntegerField("name"), new DataSourceTextField("description"));
          	ds.setClientOnly(true);
          	ds.setTestData(new DataClass[] {dc});
          
          	ListGrid lg = new ListGrid();
          	lg.setDataSource(ds);
          	lg.setUseAllDataSourceFields(true);
          	lg.setWidth(200);
          	lg.setAutoFetchData(true);
          
          	VLayout l = new VLayout();
          	l.setWidth100();
          	l.setHeight100();
          	l.addMember(lg);
          	l.draw();
          }
          This code gives me UI as displayed on the image implicit.png. Columns occupy 50% of available space. When I apply call
          Code:
          lg.setAutoFitData(Autofit.BOTH);
          UI is changed as displayed on the image autofit_applied.png. As you can see size of the ListGrid is changed and not columd width as I need. Please see image required.png. Can you please change my example code so column name will occupy only necessary space and column description remaining space (as displayed on the image required.png)?

          Thanks.

          Ales
          Attached Files

          Comment


            #6
            I need this functionality too.

            Comment

            Working...
            X