3 Replies Latest reply: Oct 23, 2003 12:39 PM by 291243 RSS

    How create table with variable number of columns?

    391584
      I am creating table data in Java. Number of columns is variable. How I can write <table> in UIX.

      Here is code of one of my unsuccessful attempt:
      ...
      <provider>

      <!- get table data like DataObjectList-->
      <data name="ReportTableData">
      <method class="app.ReportTableData" method="getTableData"/>
      </data>

      <!- get names of columns like DataObjectList-->
      <data name="ColumnNames">
      <method class="app.ReportTableData" method="getColumnNames"/>
      </data>

      </provider>
      ...
      <table data:tableData="@ReportTableData">
      <contents data:childData="@ColumnNames">
      <text data:text="nameColumn"/>
      </contents>
      </table>
      ...

      I hoped that I can get cell data by key, where key is name of column. But cells of table contain only names of columns.

      Please help me, where I mistaken?
      Thank you.
        • 1. Re: How create table with variable number of columns?
          178710
          Hi Sergey,

          The UIX table implementation relies on a childData like mechanism internally to iterate over the rows. For instance, when you databind the text attribute of the UINode used to stamp out each column, you are relying on the uix:table iterating over the table data using the data object for the current row when evaluating your column stamp.

          Setting the data:childData attribute on the table's contents element conflicts with UIX's internal iteration over the tableData. For this reason, we don't support specifying a dynamic number of table columns in UIX XML.

          This doesn't mean that you can't do it, there are different strategies. If you've got a finite and known set of columns, you can specify each possible column and then databind the rendered attribute of each one to hide and show it as appropriate. Another, often cleaner approach, is to build this subtree of UINodes in Java code.
          • 2. Re: How create table with variable number of columns?
            391584
            Thank you, Jeffrey, for your help.
            • 3. Re: How create table with variable number of columns?
              291243
              Hi Sergey,

              have a look at UIX/XML: tables, dataBound column headers - tricky!

              This way is kind of a workaround, which requires to write a somewhat special dataObject for your tableData, and it might break with furture releases but it works nicely even with the latest UIX version of JDev 10G