Skip to main content
Tweeted twitter.com/StackSalesforce/status/911228385581584384
added 25 characters in body
Source Link
Robert Sösemann
  • 38.2k
  • 29
  • 173
  • 508

I have a table grid Lightning component where a child component is trying to modify single columns. The columns are passed in as shown below.

<aura:component>
    <aura:attribute name="table" type="Object" default="{ columns: [{...}, {...}],...}" />

    <aura:iteration items="{!v.table.columns}" var="column">
        <c:child singleColumn="{!column}" />
    </aura:iteration>
</aura:component>

But changes are never reflected in the parent. It seems not to see this changes of a fragment of its table attribute.

I thought Lightning might prevent child data modifications to enforce the use of events. But this is is not the case. When I pass in the full table it works.

<aura:component>
    <aura:attribute name="table" type="Object" default="{ columns: [{...}, {...}],...}" />

    <aura:iteration items="{!v.table.columns}" var="column">
        <c:child table="{!v.table}" singleColumn="{!column}" />
    </aura:iteration>
</aura:component>

But I don't want that. That would be bad modularization and encapsulation. I want sub components only have access to the data they work on.

Any chance to get that solved? without using events?

I have a table grid Lightning component where a child component is trying to modify single columns. The columns are passed in as shown below.

<aura:component>
    <aura:attribute name="table" type="Object" default="{ columns: [{...}, {...}],...}" />

    <aura:iteration items="{!v.table.columns}" var="column">
        <c:child singleColumn="{!column}" />
    </aura:iteration>
</aura:component>

But changes are never reflected in the parent. It seems not to see this changes of a fragment of its table attribute.

I thought Lightning might prevent child data modifications to enforce the use of events. But this is is not the case. When I pass in the full table it works.

<aura:component>
    <aura:attribute name="table" type="Object" default="{ columns: [{...}, {...}],...}" />

    <aura:iteration items="{!v.table.columns}" var="column">
        <c:child table="{!v.table}" singleColumn="{!column}" />
    </aura:iteration>
</aura:component>

But I don't want that. That would be bad modularization and encapsulation. I want sub components only have access to the data they work on.

Any chance to get that solved?

I have a table grid Lightning component where a child component is trying to modify single columns. The columns are passed in as shown below.

<aura:component>
    <aura:attribute name="table" type="Object" default="{ columns: [{...}, {...}],...}" />

    <aura:iteration items="{!v.table.columns}" var="column">
        <c:child singleColumn="{!column}" />
    </aura:iteration>
</aura:component>

But changes are never reflected in the parent. It seems not to see this changes of a fragment of its table attribute.

I thought Lightning might prevent child data modifications to enforce the use of events. But this is is not the case. When I pass in the full table it works.

<aura:component>
    <aura:attribute name="table" type="Object" default="{ columns: [{...}, {...}],...}" />

    <aura:iteration items="{!v.table.columns}" var="column">
        <c:child table="{!v.table}" singleColumn="{!column}" />
    </aura:iteration>
</aura:component>

But I don't want that. That would be bad modularization and encapsulation. I want sub components only have access to the data they work on.

Any chance to get that solved without using events?

Source Link
Robert Sösemann
  • 38.2k
  • 29
  • 173
  • 508

Child components can't modify attribute data passed in from a parent component

I have a table grid Lightning component where a child component is trying to modify single columns. The columns are passed in as shown below.

<aura:component>
    <aura:attribute name="table" type="Object" default="{ columns: [{...}, {...}],...}" />

    <aura:iteration items="{!v.table.columns}" var="column">
        <c:child singleColumn="{!column}" />
    </aura:iteration>
</aura:component>

But changes are never reflected in the parent. It seems not to see this changes of a fragment of its table attribute.

I thought Lightning might prevent child data modifications to enforce the use of events. But this is is not the case. When I pass in the full table it works.

<aura:component>
    <aura:attribute name="table" type="Object" default="{ columns: [{...}, {...}],...}" />

    <aura:iteration items="{!v.table.columns}" var="column">
        <c:child table="{!v.table}" singleColumn="{!column}" />
    </aura:iteration>
</aura:component>

But I don't want that. That would be bad modularization and encapsulation. I want sub components only have access to the data they work on.

Any chance to get that solved?