Code Monkey home page Code Monkey logo

Comments (10)

EisenbergEffect avatar EisenbergEffect commented on May 3, 2024 2
<table>
  <thead>
    <tr>
      <th repeat.for="header of tabHeader">${header.name}</th>
    </tr>
  </thead>
  <tbody>
    <tr repeat.for = "line of tabData">
      <td repeat.for="field of line">${field} - ${$parent.$parent.tabHeader[$index].name</td>
    </tr>
  </tbody>
</table>

You are two levels in, so you will need to jump up two levels and then access tabHeader. It's not ideal, but it should work. I'm doing nested repeaters in my work just fine.

from framework.

zewa666 avatar zewa666 commented on May 3, 2024

Have you tried accessing the outer variables with $parent?

from framework.

bsrdjan avatar bsrdjan commented on May 3, 2024

no success that way either.

from framework.

plwalters avatar plwalters commented on May 3, 2024

Right now I don't see that there is anything available currently. If you inspect the template tag that is in the DOM you can find a primaryBehavior property that contains the executionContext which shows you what is currently available. It doesn't appear that the object is set properly yet but I am still checking in to it. If this is not yet currently available I think I have a way we can add this but I need to check with Rob first.

from framework.

bsrdjan avatar bsrdjan commented on May 3, 2024

Many thanks. The use case is rendering a bigger table. Table rows (line of tabData) contain only data values. Metadata like column tooltip, width etc. are only in tabHeader and help rendering data cells nicer, is the reason for accessing them. The proposed solution approach is fine for me.

from framework.

EisenbergEffect avatar EisenbergEffect commented on May 3, 2024

We would like to make this nicer in a future version, but it's working this way for now.

from framework.

bsrdjan avatar bsrdjan commented on May 3, 2024

sure, the elegance comes later :-)

from framework.

zewa666 avatar zewa666 commented on May 3, 2024

the with-binding might could help here so you don't have to repeat $parent.$parent over and over again. https://github.com/aurelia/templating-resources/blob/master/src/with.js

from framework.

bsrdjan avatar bsrdjan commented on May 3, 2024

just to document on more finding, uncritical for experimenting, perhaps interesting for analysis. two table elements below are identical, except $parent.$parent used in 2nd one, to adjust the width.
When the model changes both tables rendered identically (except cell width). If the model changes to recordsFound = 0 and Records=[], the view does not change at all (both tables displayed with previous model state). If the model changes again, to non zero records, all works fine. If the 2nd table below commented (with $parent.$parent), zero case works for the 1st table. In short, for the view below, the method with $parent.$parent works for non-zero case, in a test.

<div class="bodycontainer scrollable">
  <table id="resultTableBody" class="table table-hover table-striped table-condensed table-bordered">
    <tbody>
    <tr repeat.for="record of Records" click.delegate="$parent.rowSelect($index, $event)">
      <td repeat.for="field of record">${field}</td>
    </tr>
    </tbody>
  </table>
</div>


<div class="bodycontainer scrollable" >
  <table id="resultTableBody" class="table table-hover table-striped table-condensed table-bordered">
    <tbody>
    <tr repeat.for="record of Records" click.delegate="$parent.rowSelect($index, $event)">
      <td repeat.for="field of record" width="${$parent.$parent.Headers[$index][4]}">${field}</td>
    </tr>
    </tbody>
  </table>
</div>

from framework.

Kenny-Moore avatar Kenny-Moore commented on May 3, 2024

I know that this has been closed for awhile but I stumbled across this while looking for a solution. I found a better way of doing this using the <let> element. Posting here to help anyone else who is looking for a better way:

<template>
  <let $root.bind="$this"></let>
  <table>
    <thead>
      <tr>
        <th repeat.for="header of tabHeader">${header.name}</th>
      </tr>
    </thead>
    <tbody>
      <tr repeat.for = "line of tabData">
        <td repeat.for="field of line">${field} - ${$root.tabHeader[$index].name</td>
      </tr>
    </tbody>
  </table>
</template>

from framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.