Zum Hauptinhalt gehen

Zugriff auf Werte anderer Zellen innerhalb der CMS_FUNCTION "Table"

Kommentare

7 Kommentare

  • Zendesk API User
    Author: mikula - 6/8/2016 11:15

    Hallo Tobias,

    ich glaube in dem mit FS mitgelieferten beispielprojekt solltest du fündig werden schau her:

    <CMS_HEADER>

              <CMS_FUNCTION name="Table" resultname="fr_st_table">

                        <CMS_PARAM name="tableData" value="st_table" />

                        <CMS_NODE_PARAM name="tableFormat">

                                  <HEADERSPEC><![CDATA[

                                            $-- Define the table (optional caption and footer) --$

                                            <table id="table_$CMS_VALUE(#global.section.id)$"$--

                                                      --$$CMS_IF(st_sortable)$$--

                                                                --$ class="tablesorter"$--

                                                      --$$CMS_END_IF$$--

                                                      --$$CMS_IF(#global.preview)$$--

                                                                --$ style="width:99%;"$--

                                                      --$$CMS_END_IF$$--

                                                      --$$CMS_VALUE(editorId(editorName:"st_table"))$$--

                                            --$>

                                                      $CMS_IF(!st_tableheader.isEmpty)$$--

                                                                --$<caption>$--

                                                                          --$$CMS_VALUE(st_tableheader.convert2)$$--

                                                                --$</caption>$--

                                                      --$$CMS_END_IF$

                                                      $CMS_IF(!st_underline.isEmpty)$$--

                                                                --$<tfoot>

                                                                          <tr>

                                                                                    <td$--

                                                                                              --$$CMS_IF(#table.cols > 1)$$--

                                                                                                        --$ colspan="$CMS_VALUE(#table.cols)$"$--

                                                                                              --$$CMS_END_IF$$--

                                                                                    --$>$--

                                                                                              --$$CMS_VALUE(st_underline)$$--

                                                                                    --$</td>

                                                                          </tr>

                                                                </tfoot>$--

                                                      --$$CMS_END_IF$

                                                      $CMS_VALUE(#content)$

                                            </table>

                                  ]]></HEADERSPEC>

                                  <ROW number="0"><![CDATA[

                                            $-- Define the first row (optional headrow) --$

                                            $CMS_IF(st_sortable || st_topLine)$$--

                                                      --$<thead>

                                                                <tr>

                                                                          $CMS_VALUE(#content)$

                                                                </tr>

                                                      </thead>$--

                                            --$$CMS_ELSE$$--

                                                      --$<tr>

                                                                $CMS_VALUE(#content)$

                                                      </tr>$--

                                            --$$CMS_END_IF$

                                  ]]></ROW>

                                  <ROW number="ALL"><![CDATA[$-- Define the standard row --$

                                            <tr>

                                                      $CMS_VALUE(#content)$

                                            </tr>

                                  ]]></ROW>

                                  <CELL row="0" col="ALL"><![CDATA[

                                            $-- Define all cells in first row (optional headrow) --$

                                            <$--

                                                      --$$CMS_IF(st_sortable || st_topLine)$$--

                                                                --$th$--

                                                      --$$CMS_ELSE$$--

                                                                --$td$--

                                                      --$$CMS_END_IF$$--

                                                      --$$CMS_IF(#cell.rowspan > 1)$$--

                                                                --$ rowspan="$CMS_VALUE(#cell.rowspan)$"$--

                                                      --$$CMS_END_IF$$--

                                                      --$$CMS_IF(#cell.colspan > 1)$$--

                                                                --$ colspan="$CMS_VALUE(#cell.colspan)$"$--

                                                      --$$CMS_END_IF$$--

                                                      --$$CMS_IF(!#cell.align.isEmpty)$$--

                                                                --$ align="$CMS_VALUE(#cell.align)$"$--

                                                      --$$CMS_END_IF$$--

                                            --$>$--

                                                      --$$CMS_IF(!#content.isEmpty)$$--

                                                                --$$CMS_VALUE(#content)$$--

                                                      --$$CMS_ELSE$$--

                                                                --$ $--

                                                      --$$CMS_END_IF$$--

                                            --$</$--

                                                      --$$CMS_IF(st_sortable || st_topLine)$$--

                                                                --$th$--

                                                      --$$CMS_ELSE$$--

                                                                --$td$--

                                                      --$$CMS_END_IF$$--

                                            --$>

                                  ]]></CELL>

                                  <CELL row="ODD" col="ALL"><![CDATA[

                                            $-- Define all odd rows cells (optional alternating of rows) --$

                                            <td$--

                                                      --$$CMS_IF(st_altRows && !st_sortable)$$--

                                                                --$ style="background-color:#DCDCDC;"$--

                                                      --$$CMS_END_IF$$--

                                                      --$$CMS_IF(#cell.rowspan > 1)$$--

                                                                --$ rowspan="$CMS_VALUE(#cell.rowspan)$"$--

                                                      --$$CMS_END_IF$$--

                                                      --$$CMS_IF(#cell.colspan > 1)$$--

                                                                --$ colspan="$CMS_VALUE(#cell.colspan)$"$--

                                                      --$$CMS_END_IF$$--

                                                      --$$CMS_IF(!#cell.align.isEmpty)$$--

                                                                --$ align="$CMS_VALUE(#cell.align)$"$--

                                                      --$$CMS_END_IF$$--

                                            --$>$--

                                                      --$$CMS_IF(!#content.isEmpty)$$--

                                                                --$$CMS_VALUE(#content)$$--

                                                      --$$CMS_ELSE$$--

                                                                --$ $--

                                                      --$$CMS_END_IF$$--

                                            --$</td>

                                  ]]></CELL>

                                  <CELL row="ALL" col="ALL"><![CDATA[

                                            $-- Define all cells --$

                                            <$--

                                                      --$$CMS_IF((st_sortable || st_topLine) && #cell.firstRow)$$--

                                                                --$th$--

                                                      --$$CMS_ELSE$$--

                                                                --$td$--

                                                      --$$CMS_END_IF$$--

                                                      --$$CMS_IF(#cell.rowspan > 1)$$--

                                                                --$ rowspan="$CMS_VALUE(#cell.rowspan)$"$--

                                                      --$$CMS_END_IF$$--

                                                      --$$CMS_IF(#cell.colspan > 1)$$--

                                                                --$ colspan="$CMS_VALUE(#cell.colspan)$"$--

                                                      --$$CMS_END_IF$$--

                                                      --$$CMS_IF(!#cell.align.isEmpty)$$--

                                                                --$ align="$CMS_VALUE(#cell.align)$"$--

                                                      --$$CMS_END_IF$$--

                                            --$>$--

                                                      --$$CMS_IF(!#content.isEmpty)$$--

                                                                --$$CMS_VALUE(#content)$$--

                                                      --$$CMS_ELSE$$--

                                                                --$ $--

                                                      --$$CMS_END_IF$$--

                                            --$</$--

                                                      --$$CMS_IF((st_sortable || st_topLine) && #cell.firstRow)$$--

                                                                --$th$--

                                                      --$$CMS_ELSE$$--

                                                                --$td$--

                                                      --$$CMS_END_IF$$--

                                            --$>

                                  ]]></CELL>

                        </CMS_NODE_PARAM>

              </CMS_FUNCTION>

    </CMS_HEADER>

    $-- Table module  --$

    <div class="clearfix module"$CMS_VALUE(editorId())$>

              $CMS_IF(!st_headline.isEmpty)$

                        <h3$CMS_VALUE(editorId(editorName:"st_headline"))$>

                                  $CMS_VALUE(st_headline.convert2)$

                                  $CMS_RENDER(template:"tooltip",

                                              infoLayer:st_infoLayer,

                                              infoLink:st_infoLink,

                                              infoPicture:st_infoPicture,

                                              infoHeadline:st_infoHeadline)$

                        </h3>

              $CMS_END_IF$

              $CMS_VALUE(fr_st_table)$

    </div>

    $CMS_IF(st_sortable)$

              <script>

                        jQuery.noConflict();

                        jQuery(document).ready(function()

                            {

                                jQuery("#table_$CMS_VALUE(#global.section.id)$").tablesorter( { cssHeader: "sortedTableHeader"$CMS_IF(st_altRows)$, widgets: ['zebra']$CMS_END_IF$} );

                            }

                        );

              </script>

    $CMS_END_IF$

    $-- /Table module --$

    Viele grüße

    Martin

    0
  • Zendesk API User
    Author: TLNTT - 6/8/2016 11:59

    Hallo Martin,

    danke für den Vorschlag.

    Allerdings sehe ich nicht wie man in

    <CELL row="ALL" col="ALL"><![CDATA[

    auf eine bestimmt Zelle aus der ersten Zeile oder einer beliebigen anderen Zeile zugreift.

    Mir ist bewusst, dass der Abschnitt <CELL row="0" col="ALL"> zur Ausgabe von Zelleninhalten der ersten Zeile dient.

    Allerdings wollte ich ja im obigen Beispiel für  <CELL row="1" col="1"> auf den Inhalt der Zelle (r:0,c:1) zugreifen.

    Gruß

    Tobias

    0
  • Zendesk API User
    Author: mikula - 6/8/2016 16:23

    Hallo Tobias,

    nichts zu danken :smileywink:. Ich bin ganz ehrlich, ich bin mir nicht sicher ob dies ohne weiteres Möglich ist. Vielleicht hat noch wer anders eine gute Idee. Was ist denn deine Anforderung? Oder warum musst du in Zelle "A1" den Inhalt von Zelle "B3" anzeigen?

    Viele Grüße

    Martin

    0
  • Zendesk API User
    Author: TLNTT - 6/8/2016 16:41

    Hallo Martin,

    im Endeffekt geht es darum, dass jede Zelle später weiß zu welcher Spaltenüberschrift sie gehört. Das ist erstmal die feste Anforderung, die über das CSS definiert wurde um Tabellen entsprechend layouten und Ansichtsabhängig umordnen zu können.

    Da es sich ja im Hintergrund um eine Objekt Tabelle handelt, die mehrere Zellen besitzt, handelt hätte ich zumindest gedacht, dass das recht einfach möglich sein sollte auf diese zuzugreifen.

    Edit: Ich habe gerade nochmal nachgeschaut. es gibt ja in der API das Interface Table, dass genau die Methode .getCell() hätte

    /help/odfs/access/index.html?de/espirit/firstspirit/access/editor/value/Table.html

    Kann ich irgendwie in der CMS_Function darauf zugreifen?

    Das Systemobjekt #table scheint ja eine andere Klasse (de.espirit.firstspirit.generate.TableElementRenderer) zu sein, die das Interface nicht implementiert.

    Gruß

    Tobias

    0
  • Zendesk API User
    Author: TLNTT - 6/10/2016 8:21

    So,

    nach erneutem Nachdenken bin ich fündig geworden.:smileywink:

    <CELL row="ALL" col="ALL"><![CDATA[<td mapping="<NameDesDomTableObjekts>.getCell(0,#cell.col).getShortContent(null)"> $CMS_VALUE(#content)$</td>]]></CELL>


    liefert mir was ich gesucht habe.

    Vllt. hilft es ja noch jemandem in der Zukunft...

    0
  • Zendesk API User
    Author: MarcusDau - 5/4/2018 12:42

    Genau das haben wir auch gerade gesucht. Super!

    0
  • Zendesk API User
    Author: steamframe - 1/10/2019 15:50

    FYI
    Wer Probleme mit der responsive Tabelle und dem Zellenformat hat kann den korrekten Inhalt ausgeben mit:

    st_table.getCell(0, #cell.col).getNode()

    Zusätzlich muss der die Zelle dann anders abgefragt werden

    $CMS_VALUE(st_table.getCell(0, #cell.col).getNode().class)$

    $CMS_VALUE(st_table.getCell(0, #cell.col).getNode().getChildNodes())$

    $CMS_VALUE(st_table.getCell(0, #cell.col).getNode().getFirstChild().getNodeValue())$

    $CMS_VALUE(st_table.getCell(0, #cell.col).getNode().item(99))$

    0

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.