6 Replies Latest reply on Sep 28, 2009 2:59 PM by scott1

    How to set datatable width?

      Hi,
      I'm trying to set the width of columns in datatable but it is not taking the width. the following is the code.

      <rich:dataTable rows="10" id="devTable"
      value="#{myBean.devList}" var="dev">

      <rich:column width="150" sortBy="#{dev.schoolName}">
      <f:facet name="header">
      <h:outputText value="school Name"/>
      </f:facet>
      <h:outputText value="#{dev.schoolName}" />
      </rich:column>

      <rich:column width="200" sortBy="#{dev.schoolLocation}">
      <f:facet name="header">
      <h:outputText value="school location"/>
      </f:facet>
      <h:outputText value="#{dev.schoolLocation}" />
      </rich:column>
      <rich:column width="50" sortBy="#{dev.schoolDistCode}">
      <f:facet name="header">
      <h:outputText value="school dist code"/>
      </f:facet>
      <h:outputText value="#{dev.schoolDistCode}" />
      </rich:column>
      </rich:datatable>

      if I use column group then the width field is working. but if I use column group, then the sorting feature is not working.

      this seems to be a simple problem but I can't get it to work. Could you help me with a solution for this issue?

      Thanks.

        • 1. Re: How to set datatable width?
          gopib

          Hi scott1,

          I am sending sample code try this one ,

          code:
          ---------
          <f:facet name="header">
          <rich:columnGroup>
          <rich:column headerClass="headerGreen1">
          #{messages.selectall} |
          #{messages.clear}
          </rich:column>

          <rich:column headerClass="headerGreen1">
          <h:outputText>#{messages.id}</h:outputText>
          </rich:column>

          </rich:columnGroup>
          </f:facet>

          <rich:column align="center" width="60px">
          <h:selectBooleanCheckbox value="#{findSelections[user]}" />
          </rich:column>


          -----------------

          I think this is useful, working.

          • 2. Re: How to set datatable width?

            Thanks for the reply. I have tried column group before and it works. But if I use column group then the sorting feature is not working. thats why I want to set the width by not using columngroup. Is there any other way to set the width?

            Thanks.

            • 3. Re: How to set datatable width?
              nbelaevski

              Hi,

              Try using "columnsWidth" attribute

              • 4. Re: How to set datatable width?

                I tried columnswidth attribute but it didn't work. do you have any datatable samples with different column sizes (not using the columnsgroup tag) that you can share?

                Thanks.

                • 5. Re: How to set datatable width?
                  ilya_shaikovsky

                   

                  <rich:column sortBy="#{cap.state}" width="400px">

                  <rich:column sortBy="#{cap.name}" width="500">


                  both definitions just works for me at 3.3.2 snapshot.

                  • 6. Re: How to set datatable width?

                    I fixed the issue by setting the width as follows.

                    <rich:column>
                    <f:facet name="header">
                    <h:outputText value="School Code" style="font-weight:bold; width:200px;"/>
                    </f:facet>
                    <h:outputText value="#{dev.schoolCode}" />

                    </rich:column>

                    Basically I'm setting the width at the header facet level instead of rich:column tag level.

                    btw, I'm using Richfaces 3.2.1 GA version.

                    thanks for all the help.