datatable width not working

UI Components for JSF
Post Reply
grizli
Posts: 82
Joined: 11 Nov 2009, 16:36

18 Nov 2009, 17:21

When I set width for datatable to 100% it stretches the block to 100%, but columns are stuck to middle (i have it aligned to the middle) at like 40% of available space.
Is there way to force columns to utilize the whole area?
Thanks!

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

19 Nov 2009, 16:47

I think it is an issue, width should just work. I'll look into this, as a quick workaround following will make table 100%;

Code: Select all

<style type="text/css">
.yui-skin-sam .yui-dt table {
  width:100%;
}
</style>

grizli
Posts: 82
Joined: 11 Nov 2009, 16:36

19 Nov 2009, 17:23

I've applied the CSS you provided. It created a very weird rendering behavior.
Now not only vertical scroll bar is there, but also a horizontal.
I attached a screen shot.
Image

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

19 Nov 2009, 17:44

Can you post your datatable code.

grizli
Posts: 82
Joined: 11 Nov 2009, 16:36

19 Nov 2009, 20:21

Code: Select all

<div xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.prime.com.tr/ui">
        <center>
        <div class="GridContainer">
            <p:accordionPanel>
                <p:tab title="#{msgs.Filters}">
                    this is a test
                </p:tab>
            </p:accordionPanel>
            <p:dataTable id="DevTable" var="data" value="#{devs.myList}" paginator="true" rows="50" scrollable="true"
                height="650" width="100%">
                <p:column filter="true" sortBy="#{data.deviceid}" sortable="true">
                    <f:facet name="header">
                        <h:outputText value="#{devs.deviceidColumnName}" />
                    </f:facet>
                    <h:outputText value="#{data.deviceid}" />
                </p:column>
                <p:column filter="true" sortBy="#{data.assetnum}" sortable="true">
                    <f:facet name="header">
                        <h:outputText value="#{devs.assetnumColumnName}" />
                    </f:facet>
                    <h:outputText value="#{data.assetnum}" />
                </p:column>
                <p:column filter="true" sortBy="#{data.model}" sortable="true">
                    <f:facet name="header">
                        <h:outputText value="#{devs.modelColumnName}" />
                    </f:facet>
                    <h:outputText value="#{data.model}" />
                </p:column>
                <p:column filter="true" sortBy="#{data.ipaddress}" sortable="true">
                    <f:facet name="header">
                        <h:outputText value="#{devs.ipaddressColumnName}" />
                    </f:facet>
                    <h:outputText value="#{data.ipaddress}" />
                </p:column>
            </p:dataTable>
        </div>
        </center>
</div>

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

20 Nov 2009, 00:45

I didn't know that your datatable is scrollable, so first css I've provided won't fit well to the scrollable table. When using a scrollable table,try setting a fixed with or height. Scrolling is meant to be used like that. So it'd be sth like width:400px where 400px is less than the calculated width of the content. Also note that column widths can be controlled with width attribute. Hope these help.

grizli
Posts: 82
Joined: 11 Nov 2009, 16:36

24 Nov 2009, 16:52

Is there a way to have columns accept width as a percent too?
Right now it is ParseInt() so it fails.

I can't have fixed width as I don't know client's size of the screen. I'm going to try to come up with something via javascript.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 67 guests