C: Use of foreach status. Index row index [reprint!]

Source: Internet
Author: User

Use seam to create a project, display a custom list output, define the table Title List headerlist and data list <list> datalist respectively, and then implement two display modes. One is the normal table mode, where a piece of data is displayed in one row. In this way, we can use RICH: datatable, and then use RICH: columns for custom iterations, note that index indicates the row index of each row of data. The Code is as follows:

 

 

XHTML code {
DP. Sh. toolbar. copytoclipboard (this); Return false;
} "Href =" http://writeblog.csdn.net/# ">
  1. <RICH: datatableValue = "# {orderresdetailhome. datalist}" Var = "list" rows = "10" style = "width: 100%;" rowkeyvar = "rownum">
  2. <RICH: column>
  3. <F: facetName = "Header">Serial number</F: facet>
  4. # {Rownum + 1}
  5. </Rich: column>
  6. <RICH: ColumnsValue = "# {orderresdetailhome. headerlist}" Var = "dataheader" Index = "idx">
  7. <F: facetName = "Header"># {Dataheader}</F: facet>
  8. # {List [idx + 2]}
  9. </Rich: columns>
  10. </Rich: datatable>
<RICH: datatable value = "# {orderresdetailhome. datalist} "Var =" list "rows =" 10 "style =" width: 100%; "rowkeyvar =" rownum "> <RICH: column> <F: facet name = "Header"> NO. </F: facet >#{ rownum + 1} </rich: column> <RICH: columns value = "# {orderresdetailhome. headerlist} "Var =" dataheader "Index =" idx "> <F: facet name =" Header ">#{ dataheader} </F: facet >#{ list [idx + 2]} </rich: columns> </rich: datatable>

 

In the Code # {list [idx + 2]}, adding 2 is because the data column starts with two columns and multiple outputs are used as other columns.

 

There is also a way to display data in a grid instead of displaying data in one row, in this case, the rich: Columns cannot be used for data iteration. You can consider using C: foreach, where varstatus = "status" can be defined ",

Obtain the row index of each row of data from # {status. Index}. The Code is as follows:

 

 

XHTML code {
DP. Sh. toolbar. copytoclipboard (this); Return false;
} "Href =" http://writeblog.csdn.net/# ">
  1. <RICH: DataGridVar = "list"
  2. Columns = "1"
  3. Elements = "10"
  4. Rowkeyvar = "rownum"
  5. Value = "# {orderresdetailhome. datalist }">
  6. <H: panelgridColumns = "1">
  7. <S: decorateTemplate = "/layout/display.xhtml">
  8. <UI: DefineName = "label">Serial number</UI: Define>
  9. # {Rownum + 1}
  10. </S: decorate>
  11. <C: foreachVar = 'datahead' items = '# {orderresdetailhome. headerlist}' varstatus = "status">
  12. <S: decorateTemplate = "/layout/display.xhtml">
  13. <UI: DefineName = "label"># {Dataheader}</UI: Define>
  14. # {List [status. index + 2]}
  15. </S: decorate>
  16. </C: foreach>
  17. </H: panelgrid>
  18. </Rich: DataGrid>
<RICH: DataGrid Var = "list" columns = "1" elements = "10" rowkeyvar = "rownum" value = "# {orderresdetailhome. datalist} "> 

The latter is suitable for small screen devices.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.