Render datatable rows horizontally

Suppose I have a result set with one column and many rows. Is there a way to render it in a datatable using horizontal alignment rather than vertical.
Example: Assuming that datatable happens to have 5 rows (please note that number of rows may not be known until runtime). It would typically render vertically in the following fashion:
Col1Row1
Col1Row2
Col1Row3
Col1Row4
Col1Row5
Instead, I would like to be presented in the following fashion:
Col1Row1 Col1Row2 Col1Row3
Col1Row4 Col1Row5.
Obviously, it would be nice if allowed to specify the number of columns to display prior to wrapping into a new line or row.
In the absence of writing a custom component to do that. Is there a way to do it with some JSF tag that I have not found (datatable did not seem to have the needed flexibility).

You can write a wrapper around your resultset which will expose the data as a two dimensional object
Then you can use something like
<h:dataTable ..... var="listItem">
  <h:column>
    <h:outputText value="#{listItem[0]}"/>
    <h:outputText value="#{listItem[1]}"/>
    <h:outputText value="#{listItem[2]}"/>
  </h:column>
</h:dataTable>Of course in the above approach, you would have to know the number of columns you would like to have in advance.

Similar Messages

  • Display datatable rows horizontally

    How can the rows of a jsf datatable be displayed horizontally?

    Thanks for your reply. What you have provided is a great link. But I am not able to find the page that describes displaying rows horizontally. Can you please specify the page no.
    Thanks.

  • Using javascript to detect the onclick event over a datatable row

    Hi all,
    I'm working with JSF 1.2 R.I. and I would like to add some javascript to my datatable to be able to control the onclick event on a row.
    At the moment I have just added a checkbox to be able to know which row the user wants to select but I'm not satisfied with this solution.
    <h:dataTable
    value="#{person_iupopulations_Observation.customer}" var="customer"
    rowClasses="evenRow,oddRow"
    cellspacing="0">
    <h:column>
    <f:facet name="header">
    <h:outputText value="Select" />
    </f:facet>
    <h:selectBooleanCheckbox value="" onclick="getRow(this)">
    </h:selectBooleanCheckbox>
    </h:column>
    <h:column>
    <f:facet name="header">
    <h:outputText value="Name" />
    </f:facet>
    <h:outputText value="#{customer.Name}"></h:outputText>
    </h:column>
    </h:dataTable>
    What I would like to achieve is:
    When the user clicks the row (wherever, not only the checkbox) the checkbox changes to the new value depending, off course, on the user's selection.
    For this purpose I would need to add the onclick event to every row and associate it to a javascript function to update the checkbox.
    Can anybody help me please.
    I appreciate any suggestion.
    Thanks in advance!

    I am looking for answers on how to use javascript to detect the onclick event over a datatable row . I have a selectBooleanCheckBox in one of the columns in the every row in the table. On click of the checkbox in any row of the table, I want to get some values from the selected row and also verify that the rest of the checkboxes in all the other columns are unchecked. I want to do this using javascript. If any of you have answers, please repsond. Thanks.

  • When mouse move over datatable row colour should changes?

    When the mousepointer is moved over a datatable row, the colour of that perticular row should change( as in http://www.print-driver.com/order/), How can I do this? (will CSS help?)
    Thank you very much.

    Hi,<p>
    If it is a standard HTML table, do it in CSS. Plenty of examples out there - look at Tor Norbye's weblog for a specific example using JSC and changing the color of cells in a standard HTML table.
    <p>
    I have tried using a JSF table, but to no success. When I look at the generated HTML code, I see it referenceing a style class and style sheet that is not in my working directories (i.e. /creator/projects/webrpoject/web/resources).
    <p>
    I will find that one and try to edit it to see if it can be tweaked in CSS.
    <p>
    Meanwhile, good luck !

  • DataTable.Rows.Count property is occasionally wrong

    I have a web service in C#.NET which calls a stored procedure using ADO.NET. The stored procedure is always returning 1 row, which is then loaded into a DataTable. The Rows.Count property of the DataTable is then examined.
    When this web service is called repeatedly with numerous requests, it occasionally returns Rows.Count as 0 when it should be 1. I have debugged and examined it at runtime and found that there is indeed 1 row in the datatable, but that the Rows.Count property
    is 0.
    Is this a known bug?
    I'm using .Net Framework 2.0
    Note: This is an issue that occurs very rarely. My testing shows that it takes about 90 minutes to recreate it when you have 2 concurrent processes sending requests repeatedly at a rate of about 10 requests per second.

    Are you sure that there aren't multiple threads access the DataTable?
    Can you post a repro? 
    David
    David http://blogs.msdn.com/b/dbrowne/

  • Getting values from datatable row action

    Hi,
    I have a data table defined to load dynamic values. It works fine. Now I want to add a Row Action and then after clicking it it should be forwarded to the next page which displays other details of the row.
    Now the problem is I dont understand how can i fetch a particular column value in the doRowAction method. I know this is a very basic question but please help!!..

    Not sure where you're talking about with "doRowAction()" but this article might give useful background information and new insights: http://balusc.blogspot.com/2006/06/using-datatables.html

  • How to add a message to a field in a dataTable row?

    I have a dataTable with a var "selectedUser". Each row has a 2 fields: username & password, both editable and 2 buttons: save and delete. In the "UsersControllerBean.updateUser" method associated with the update button, I want to be able to add an error message to the field on the corresponding row where the button has been clicked. How can I retrieve the client Id of the field from the "selectedUser" var associated with the dataTable (that I get from the RequestMap) to add the message to it?
    Is there an easier way of doing this? (no, thanks no link button!)
    Thanks
    Fred
                   <h:form id="users">
                   <h:dataTable border="1" width="100%" value="#{UsersControllerBean.usersList}" var="selectedUser">
                        <h:column>
                             <f:facet name="header">
                                       <h:outputText value="Id"/>
                             </f:facet>
                             <h:outputText value="#{selectedUser.userId}"/>
                        </h:column>
                        <h:column>
                             <f:facet name="header">
                                       <h:outputText value="Name"/>
                             </f:facet>
                             <h:inputText id="username" required="true" value="#{selectedUser.username}"/>
                             <h:message for="username" style="color: red"/>
                        </h:column>
                        <h:column>
                             <f:facet name="header">
                                       <h:outputText value="Password"/>
                             </f:facet>
                             <h:inputText id="password" value="#{selectedUser.password}"/>
                             <h:message for="password" style="color: red"/>
                        </h:column>
                        <h:column>
                             <f:facet name="header">
                                       <h:outputText value="Actions"/>
                             </f:facet>
                             <h:commandButton value="Save" action="#{UsersControllerBean.updateUser}"/>
                             <f:verbatim>��</f:verbatim>
                             <h:commandButton value="Delete" action="#{UsersControllerBean.deleteUser}" immediate="true"/>
                        </h:column>
                   </h:dataTable>
                   </h:form>

    Dear Friends,
    Finally, I got the answer.
    I required to add the messages to error log for invoice. Error log is displayed in Tree format.
    The error log getting displayed while processing invoice with help of table VBSK.
    We can update the VBSK table information with required message to put in log.
    Best regards,
    Amol Chaudhari.

  • How to track changes in DataTable rows?

    Hi,
    I'm wondering what are you using to track changes in datatables. As far as I can tell, there is no way to know what editable componentes in each row have been modified. That forces you to clone() the objects in the rows to compare them after the user submits the form.
    This works without problems, but somewhat I feel it's dirty. What approach are you using ?
    Best regards,
    - Juan

    I have not tried that. But you could wire a value change listner to track what is changing. Or do do what you are doing now. Or wait for SDO (service data object) to become part of J2EE specs (coming soon)

  • How to get  h:datatable rows in the managed bean

    Hi All,
    I am showing a table with some columns in a page. I have submit button in that page.
    After submission of page,I need to get the rows displayed in the page.
    how can i acheive it?
    is binding attribute helps?
    please provide some info..
    thanks in advance..
    chenna........

    BalusC,
    thanks for ur reply..
    Let me reframe my question..
    here is my code snippet..
    // bean
    private ArrayList<MyVO> myList;
    // setter and getter methods for myList......
    ArrayList<MyVO> getRows(){
    resultFromDB=getMyRows();// call getMyRows() DAO method for results
    this.myList=resultsFromDB;
    return resultFromDB;
    In the jsp and displaying all the rows using<h:datatable id="someId" value="#{someBean.rows}"
    so far good.
    In this page i have one submit button which will call confirm() of my managed bean.
    In the confirm() i need to get all the rows. i.e; i need to get the myList.
    I dont want to call the getRows() method again(since it is DB hit)
    But myList is empty in my confirm method.
    my managed bean is in request scope.
    if i change it to session it is working.but i need request scope only.
    I tried with <t:saveState value="#{someBean}" /> but no luck..
    Later i have taken HtmlDataTable reference with setter and getters in the bean and bind this reference in <h:datatable>.
    and tried to disply the htmlDataTable rowCount...
    then im getting NotSerializableException though my bean is implementing Serializable interface..
    Please give some suggestion in this
    thanks....

  • JSF Datatable row data - Expand/Collapse

    Hi,
    I just started learning the JSF concepts. I read articles by BalusC which are very clear and easily understandable. Thanks to BalusC.
    I have a requirement to implement expand and collapse data using JSF datatable. The data comes from the backing bean is in the form of java.util.List which contains StudentInfo. I will have to display following data from the list.
    *{color:#0000ff}name {color}(this is to be displayed a link), firstname, lastname, dob*
    I am able to display the data in a nice formatted table using h:datatable. My main hurdle is to display an expanded info when the name link is clicked. The expanded info should be displayed below the row spanning all columns. The additional info being the comments, instructions whic are the part of the row data. Here is the code describing the StudentInfo.
    Appreciate if someone help me with suggestions. Very helpful if any sample code is avaialble.
    Regards,
    Smitha
    public class StudentInfo {
    //Following fields to be shown in row data
    private String name;
    private String firstname;
    private String lastname;
    private String dob;
    //Following fields to be shown in expanded form
    private String comments;
    private String instructions;
    public String getName() {
    return name;
    public void setName(String name) {
    this.name = name;
    public String getFirstname() {
    return firstname;
    public void setFirstname(String firstname) {
    this.firstname = firstname;
    public String getLastname() {
    return lastname;
    public void setLastname(String lastname) {
    this.lastname = lastname;
    public String getDob() {
    return dob;
    public void setDob(String dob) {
    this.dob = dob;
    public String getComments() {
    return comments;
    public void setComments(String comments) {
    this.comments = comments;
    public String getInstructions() {
    return instructions;
    public void setInstructions(String instructions) {
    this.instructions = instructions;
    }

    That's not possible with plain h:dataTable.
    Consider Tomahawk t:dataList where in you can specify rows and colspans yourself using plain HTML. Show/hide rows should be easy with JavaScript.

  • How to: window confirmation in a datatable row

    Hi.
    I would like to know if it possible to open a window confirmation (Yes,No) from a row selector in a datatable. The columns of the datatable are h:outputText, but the examples I have seen use always h:commandLink and h:commandButton.
    I want to stop the process when I select a row in datatable in case you select No and let the process in case Yes.
    if this possible??
    Thanks

    For better user experience you need to use standard html interaction tags (links or buttons) .
    You can't use onclick attribute on h:outputText as it haven't.

  • Optical line break in dataTable row ?!

    Hello,
    I have to work with very large tables (in width and heigth) and use a f:datatable to publish them on the screen. Now I want to prevent the user scrolling to the left and the right while viewing the table.
    I tried to insert a f:panelgrid in the f:datatable, but my IDE said, that this is not a good idea.
    Is there any chance to split one row into two rows, but only for the presentation?!
    Has anybody an idea?
    Thanks,
    Thomas

    Uhh,
    it is possible. Just use the halfe set of coulmn's and create in each cell a new table with two rows.
    Bye,
    Thomas

  • How the get the current dataTable row

    I have a dataTable with the value from List in the BackingBean.
    The script is printing the list elements, and I want to get the number of each row. I don't have any enumaration in for the records. Can it be done simply?
    Thanks for answer.

    You can use HtmlDataTable#getRowData() to retrieve the current row object in the iteration.
    But you just want to retrieve row numbers? Then rather use HtmlDataTable#getRowIndex().
    Also see http://balusc.xs4all.nl/srv/dev-jep-dat.html for several datatable use examples.

  • DataTable Row

    Hi all,
    I have a dataTable displaying data. For each row I wish to have a hover over to display addional information about that row of data.
    The trouble is I can not see a way to add a title attribute to the whole row. I have been able to use the title attribue on the outputText's for the table tag but this only gives me a hover over when I am over the text in that row.
    Does any body know how to get a title attribue for the TR's or maybe able to add a onmouseover and onmoueout so I could add a custom hover?
    If its not possible could somebody just confirm that as I am currently looking around the web to see if I can find a better to sollution to what I have.
    Thanks
    Dale

    Use JS+DOM to add the title attribute onload.

  • How to add component dynamically to datatable row?

    Hi,
    I have a dropdown in one column of table.Depending upon selected value in that dropdown, I want to add some components dynamically only in that row.How to do this?
    I have seen that findComponent() method doesnt accept clientId.Is there any other way to use clientId to search components. Because clientIds contain row numbers.
    Thanks in advance,
    Chitra.

    Bind the component to the bean using its 'binding' attribute. Then use it instead.

Maybe you are looking for

  • How can you get your i pod touch screen fixed

    How can you get your screen on an i pod fixed

  • My 2nd Generation iPod is not recognized by iTunes 10.5

    I have a 2nd Generation iPod Touch running on 4.2.1. I recently updated my iTunes to 10.5 but now my device is not appearing in iTunes. My computer still recognizes the device but iTunes does not.

  • OMB: Index creation in a cube_table

    Hello. I'm developing a OMB script and I don't know how to get what you want: I need to create bitmap indexes in a cube_table for those all columns that reference a dimension. I'm able to get de references but I am not able to link them to the cube_t

  • Registering AS with new OID

    Dear all, We have an existing Application server registered with OID. We are upgrading our AIX server to 6.1 so will configure new OID on the new server. How to unregister an existing Application server from one OID and register with another OID. Tha

  • Brazil: Copy Transfer Order header text to Nota Fiscal

    Good morning, all! The company I work for has a process in which certain non-retail goods are transferred from one store (or distribution center) to another. The transfer order is created in ME27. After that, the user creates a shipping document and