Comments (10)
<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.
Have you tried accessing the outer variables with $parent?
from framework.
no success that way either.
from framework.
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.
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.
We would like to make this nicer in a future version, but it's working this way for now.
from framework.
sure, the elegance comes later :-)
from framework.
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.
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.
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)
- Many aurelia libraries are broken in iOS 16 HOT 47
- example link for codesandbox in README.md HOT 1
- How to fetch data from a JSON file in aurelia framework? HOT 4
- How to bind repeat.for on the async array variable? HOT 5
- aurelia.use.developmentLogging(environment.debug ? 'debug' : 'warn'); is broken? HOT 5
- Building all public files to www folder
- set object that has observed properties breaks the observing system HOT 4
- Issue with compose element and composition
- Combination of `@dynamicOptions` and `primaryProperty` HOT 5
- Publish Aurelia project with visual studio 2017. HOT 1
- Allow better typing for module configuration HOT 4
- Upgrade gulp to v4.
- Staging a component for testing
- UI is not re-rendered when Set is used. HOT 5
- Binding Engine seems to strip CR from text HOT 1
- Component inheritance with bindings on the base doesn't work as expected
- Content of repeat for on tr tag rendered outside of tag HOT 1
- How to use aurelia in qiankun HOT 2
- Content editable div inside a parent div that has a mousedown event on it cannot be edited in Aurelia HOT 1
- npm audit warning for aurelia-framework - XSS vulnerability in default HTML sanitizer implementation HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from framework.