Is it not possible to get a parent field in a datatable column specification, for a Lightning Web Component?2019 Community Moderator ElectionRetrieve shared data extension column names with SSJS marketing cloudGet the values of checkboxes (in a lightning component)Lightning Component works on Sandbox but not on ProductionWhy Lightning Web ComponentNot able to render dynamic Lightning Web ComponentSalesforce Lightning Web ComponentLightning Web Component for table rows and cellsLightning web component object referenceUnable to set component outside of FileReader().onloadSyntax to dynamically set nested property?

Sequence of Tenses: Translating the subjunctive

Is there a korbon needed for conversion?

Pole-zeros of a real-valued causal FIR system

How to run a prison with the smallest amount of guards?

I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?

How long to clear the 'suck zone' of a turbofan after start is initiated?

Escape a backup date in a file name

What is the difference between "behavior" and "behaviour"?

How easy is it to start Magic from scratch?

Opposite of a diet

Crossing the line between justified force and brutality

What is the best translation for "slot" in the context of multiplayer video games?

Class Action - which options I have?

System.debug(JSON.Serialize(o)) Not longer shows full string

How does it work when somebody invests in my business?

How does the UK government determine the size of a mandate?

How do I go from 300 unfinished/half written blog posts, to published posts?

What does "I’d sit this one out, Cap," imply or mean in the context?

Why are there no referendums in the US?

How do I rename a Linux host without needing to reboot for the rename to take effect?

Go Pregnant or Go Home

Is a stroke of luck acceptable after a series of unfavorable events?

How do I find the solutions of the following equation?

Why not increase contact surface when reentering the atmosphere?



Is it not possible to get a parent field in a datatable column specification, for a Lightning Web Component?



2019 Community Moderator ElectionRetrieve shared data extension column names with SSJS marketing cloudGet the values of checkboxes (in a lightning component)Lightning Component works on Sandbox but not on ProductionWhy Lightning Web ComponentNot able to render dynamic Lightning Web ComponentSalesforce Lightning Web ComponentLightning Web Component for table rows and cellsLightning web component object referenceUnable to set component outside of FileReader().onloadSyntax to dynamically set nested property?










5















Working with a prototype of a lightning web component, I get that the datatable, just like its Aura brother, needs the columns to be manually specified.



That being said, I have the following specification for a datatable that receives pricebook entries:



const columns = [
label: 'Name', fieldName: 'Product2.Name'
]


The names do not display on the component, but if I use a forEach to list the data retrieved by the component, I get the products names, like in:



connectedCallback() 
getProducts( pricebookId: this.pricebookId, countLimit: 4 )
.then(result =>
this.products = result
this.products.forEach(p =>
console.log(p.Product2) // Proxy object is displayed
console.log(p.Product2.Name) // The name is displayed
);
this.tableIsLoading = false
)
.catch(error =>
console.error(error)
)




If the datatable component does not support this, then the correct way of dealing with this is to work with the retrieved data, and build a new list with direct access to the data (no parent-child objects), or to edit the current data and include fields that I can access?



For example, should I iterate the result data and add a productName attribute to the elements, and then set 'productName' as the attribute on the column variable?



Edit: just noticed that you can't iterate the data list and create a new productName property. You end up with a TypeError: 'set' on proxy: trap returned falsish for property 'productName'.










share|improve this question




























    5















    Working with a prototype of a lightning web component, I get that the datatable, just like its Aura brother, needs the columns to be manually specified.



    That being said, I have the following specification for a datatable that receives pricebook entries:



    const columns = [
    label: 'Name', fieldName: 'Product2.Name'
    ]


    The names do not display on the component, but if I use a forEach to list the data retrieved by the component, I get the products names, like in:



    connectedCallback() 
    getProducts( pricebookId: this.pricebookId, countLimit: 4 )
    .then(result =>
    this.products = result
    this.products.forEach(p =>
    console.log(p.Product2) // Proxy object is displayed
    console.log(p.Product2.Name) // The name is displayed
    );
    this.tableIsLoading = false
    )
    .catch(error =>
    console.error(error)
    )




    If the datatable component does not support this, then the correct way of dealing with this is to work with the retrieved data, and build a new list with direct access to the data (no parent-child objects), or to edit the current data and include fields that I can access?



    For example, should I iterate the result data and add a productName attribute to the elements, and then set 'productName' as the attribute on the column variable?



    Edit: just noticed that you can't iterate the data list and create a new productName property. You end up with a TypeError: 'set' on proxy: trap returned falsish for property 'productName'.










    share|improve this question


























      5












      5








      5


      1






      Working with a prototype of a lightning web component, I get that the datatable, just like its Aura brother, needs the columns to be manually specified.



      That being said, I have the following specification for a datatable that receives pricebook entries:



      const columns = [
      label: 'Name', fieldName: 'Product2.Name'
      ]


      The names do not display on the component, but if I use a forEach to list the data retrieved by the component, I get the products names, like in:



      connectedCallback() 
      getProducts( pricebookId: this.pricebookId, countLimit: 4 )
      .then(result =>
      this.products = result
      this.products.forEach(p =>
      console.log(p.Product2) // Proxy object is displayed
      console.log(p.Product2.Name) // The name is displayed
      );
      this.tableIsLoading = false
      )
      .catch(error =>
      console.error(error)
      )




      If the datatable component does not support this, then the correct way of dealing with this is to work with the retrieved data, and build a new list with direct access to the data (no parent-child objects), or to edit the current data and include fields that I can access?



      For example, should I iterate the result data and add a productName attribute to the elements, and then set 'productName' as the attribute on the column variable?



      Edit: just noticed that you can't iterate the data list and create a new productName property. You end up with a TypeError: 'set' on proxy: trap returned falsish for property 'productName'.










      share|improve this question
















      Working with a prototype of a lightning web component, I get that the datatable, just like its Aura brother, needs the columns to be manually specified.



      That being said, I have the following specification for a datatable that receives pricebook entries:



      const columns = [
      label: 'Name', fieldName: 'Product2.Name'
      ]


      The names do not display on the component, but if I use a forEach to list the data retrieved by the component, I get the products names, like in:



      connectedCallback() 
      getProducts( pricebookId: this.pricebookId, countLimit: 4 )
      .then(result =>
      this.products = result
      this.products.forEach(p =>
      console.log(p.Product2) // Proxy object is displayed
      console.log(p.Product2.Name) // The name is displayed
      );
      this.tableIsLoading = false
      )
      .catch(error =>
      console.error(error)
      )




      If the datatable component does not support this, then the correct way of dealing with this is to work with the retrieved data, and build a new list with direct access to the data (no parent-child objects), or to edit the current data and include fields that I can access?



      For example, should I iterate the result data and add a productName attribute to the elements, and then set 'productName' as the attribute on the column variable?



      Edit: just noticed that you can't iterate the data list and create a new productName property. You end up with a TypeError: 'set' on proxy: trap returned falsish for property 'productName'.







      javascript lightning-web-components






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday







      Renato Oliveira

















      asked yesterday









      Renato OliveiraRenato Oliveira

      5,02211955




      5,02211955




















          1 Answer
          1






          active

          oldest

          votes


















          4














          The lightning:datatable assumes that the field name is not an object, but you can have a period in a field name.



          Consider this data:



          [ 'Product.Name': 'Hello' , 'Product': 'Name': 'World' }]


          If you had data like this, the output in lightning:datatable would be "Hello", not "World".



          Here's a copy-paste example for you:



          <aura:application extends="force:slds">
          <!-- attributes -->
          <aura:attribute name="data" type="List" default="['Product.Name':'Hello', 'Product':'Name':'World','id':'5']"/>
          <aura:attribute name="columns" type="List" default="[ 'label':'Product Name','fieldName':'Product.Name']" />

          <!-- the container element determine the height of the datatable -->
          <div style="height: 300px">
          <lightning:datatable
          keyField="id"
          data="! v.data "
          columns="! v.columns "
          hideCheckboxColumn="true"/>
          </div>

          </aura:application>


          This is true for both the Aura and Web component versions.



          So, to answer your question, yes, you will need to do some post-processing on your data. It can be as simple as:



          this.products = result.map(
          record => Object.assign(
          "Product2.Name": record.Product2.Name ,
          record
          )
          );





          share|improve this answer

























          • That doesn't seem to work. I get a TypeError: 'set' on proxy: trap returned falsish for property 'Product2.Name' inside the forEach.

            – Renato Oliveira
            yesterday











          • @RenatoOliveira My aura demo works correctly; let me set up a lwc real quick, I'll be back.

            – sfdcfox
            yesterday






          • 1





            @RenatoOliveira Network issues, but I came up with a working demo for LWC-style JS as well. Let me know if that helps.

            – sfdcfox
            yesterday






          • 2





            That worked. That's really nice, using map and assign to avoid the proxy issues.

            – Renato Oliveira
            yesterday






          • 1





            @RenatoOliveira I am not sure what accepted best practices are, but I too flatten my datatable data. However, I tend to avoid dot notation in flattening just because it's typically associated with JS object properties. You might consider usage of _ in place of .

            – tsalb
            20 hours ago











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "459"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f255418%2fis-it-not-possible-to-get-a-parent-field-in-a-datatable-column-specification-fo%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          4














          The lightning:datatable assumes that the field name is not an object, but you can have a period in a field name.



          Consider this data:



          [ 'Product.Name': 'Hello' , 'Product': 'Name': 'World' }]


          If you had data like this, the output in lightning:datatable would be "Hello", not "World".



          Here's a copy-paste example for you:



          <aura:application extends="force:slds">
          <!-- attributes -->
          <aura:attribute name="data" type="List" default="['Product.Name':'Hello', 'Product':'Name':'World','id':'5']"/>
          <aura:attribute name="columns" type="List" default="[ 'label':'Product Name','fieldName':'Product.Name']" />

          <!-- the container element determine the height of the datatable -->
          <div style="height: 300px">
          <lightning:datatable
          keyField="id"
          data="! v.data "
          columns="! v.columns "
          hideCheckboxColumn="true"/>
          </div>

          </aura:application>


          This is true for both the Aura and Web component versions.



          So, to answer your question, yes, you will need to do some post-processing on your data. It can be as simple as:



          this.products = result.map(
          record => Object.assign(
          "Product2.Name": record.Product2.Name ,
          record
          )
          );





          share|improve this answer

























          • That doesn't seem to work. I get a TypeError: 'set' on proxy: trap returned falsish for property 'Product2.Name' inside the forEach.

            – Renato Oliveira
            yesterday











          • @RenatoOliveira My aura demo works correctly; let me set up a lwc real quick, I'll be back.

            – sfdcfox
            yesterday






          • 1





            @RenatoOliveira Network issues, but I came up with a working demo for LWC-style JS as well. Let me know if that helps.

            – sfdcfox
            yesterday






          • 2





            That worked. That's really nice, using map and assign to avoid the proxy issues.

            – Renato Oliveira
            yesterday






          • 1





            @RenatoOliveira I am not sure what accepted best practices are, but I too flatten my datatable data. However, I tend to avoid dot notation in flattening just because it's typically associated with JS object properties. You might consider usage of _ in place of .

            – tsalb
            20 hours ago
















          4














          The lightning:datatable assumes that the field name is not an object, but you can have a period in a field name.



          Consider this data:



          [ 'Product.Name': 'Hello' , 'Product': 'Name': 'World' }]


          If you had data like this, the output in lightning:datatable would be "Hello", not "World".



          Here's a copy-paste example for you:



          <aura:application extends="force:slds">
          <!-- attributes -->
          <aura:attribute name="data" type="List" default="['Product.Name':'Hello', 'Product':'Name':'World','id':'5']"/>
          <aura:attribute name="columns" type="List" default="[ 'label':'Product Name','fieldName':'Product.Name']" />

          <!-- the container element determine the height of the datatable -->
          <div style="height: 300px">
          <lightning:datatable
          keyField="id"
          data="! v.data "
          columns="! v.columns "
          hideCheckboxColumn="true"/>
          </div>

          </aura:application>


          This is true for both the Aura and Web component versions.



          So, to answer your question, yes, you will need to do some post-processing on your data. It can be as simple as:



          this.products = result.map(
          record => Object.assign(
          "Product2.Name": record.Product2.Name ,
          record
          )
          );





          share|improve this answer

























          • That doesn't seem to work. I get a TypeError: 'set' on proxy: trap returned falsish for property 'Product2.Name' inside the forEach.

            – Renato Oliveira
            yesterday











          • @RenatoOliveira My aura demo works correctly; let me set up a lwc real quick, I'll be back.

            – sfdcfox
            yesterday






          • 1





            @RenatoOliveira Network issues, but I came up with a working demo for LWC-style JS as well. Let me know if that helps.

            – sfdcfox
            yesterday






          • 2





            That worked. That's really nice, using map and assign to avoid the proxy issues.

            – Renato Oliveira
            yesterday






          • 1





            @RenatoOliveira I am not sure what accepted best practices are, but I too flatten my datatable data. However, I tend to avoid dot notation in flattening just because it's typically associated with JS object properties. You might consider usage of _ in place of .

            – tsalb
            20 hours ago














          4












          4








          4







          The lightning:datatable assumes that the field name is not an object, but you can have a period in a field name.



          Consider this data:



          [ 'Product.Name': 'Hello' , 'Product': 'Name': 'World' }]


          If you had data like this, the output in lightning:datatable would be "Hello", not "World".



          Here's a copy-paste example for you:



          <aura:application extends="force:slds">
          <!-- attributes -->
          <aura:attribute name="data" type="List" default="['Product.Name':'Hello', 'Product':'Name':'World','id':'5']"/>
          <aura:attribute name="columns" type="List" default="[ 'label':'Product Name','fieldName':'Product.Name']" />

          <!-- the container element determine the height of the datatable -->
          <div style="height: 300px">
          <lightning:datatable
          keyField="id"
          data="! v.data "
          columns="! v.columns "
          hideCheckboxColumn="true"/>
          </div>

          </aura:application>


          This is true for both the Aura and Web component versions.



          So, to answer your question, yes, you will need to do some post-processing on your data. It can be as simple as:



          this.products = result.map(
          record => Object.assign(
          "Product2.Name": record.Product2.Name ,
          record
          )
          );





          share|improve this answer















          The lightning:datatable assumes that the field name is not an object, but you can have a period in a field name.



          Consider this data:



          [ 'Product.Name': 'Hello' , 'Product': 'Name': 'World' }]


          If you had data like this, the output in lightning:datatable would be "Hello", not "World".



          Here's a copy-paste example for you:



          <aura:application extends="force:slds">
          <!-- attributes -->
          <aura:attribute name="data" type="List" default="['Product.Name':'Hello', 'Product':'Name':'World','id':'5']"/>
          <aura:attribute name="columns" type="List" default="[ 'label':'Product Name','fieldName':'Product.Name']" />

          <!-- the container element determine the height of the datatable -->
          <div style="height: 300px">
          <lightning:datatable
          keyField="id"
          data="! v.data "
          columns="! v.columns "
          hideCheckboxColumn="true"/>
          </div>

          </aura:application>


          This is true for both the Aura and Web component versions.



          So, to answer your question, yes, you will need to do some post-processing on your data. It can be as simple as:



          this.products = result.map(
          record => Object.assign(
          "Product2.Name": record.Product2.Name ,
          record
          )
          );






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited yesterday

























          answered yesterday









          sfdcfoxsfdcfox

          261k12209453




          261k12209453












          • That doesn't seem to work. I get a TypeError: 'set' on proxy: trap returned falsish for property 'Product2.Name' inside the forEach.

            – Renato Oliveira
            yesterday











          • @RenatoOliveira My aura demo works correctly; let me set up a lwc real quick, I'll be back.

            – sfdcfox
            yesterday






          • 1





            @RenatoOliveira Network issues, but I came up with a working demo for LWC-style JS as well. Let me know if that helps.

            – sfdcfox
            yesterday






          • 2





            That worked. That's really nice, using map and assign to avoid the proxy issues.

            – Renato Oliveira
            yesterday






          • 1





            @RenatoOliveira I am not sure what accepted best practices are, but I too flatten my datatable data. However, I tend to avoid dot notation in flattening just because it's typically associated with JS object properties. You might consider usage of _ in place of .

            – tsalb
            20 hours ago


















          • That doesn't seem to work. I get a TypeError: 'set' on proxy: trap returned falsish for property 'Product2.Name' inside the forEach.

            – Renato Oliveira
            yesterday











          • @RenatoOliveira My aura demo works correctly; let me set up a lwc real quick, I'll be back.

            – sfdcfox
            yesterday






          • 1





            @RenatoOliveira Network issues, but I came up with a working demo for LWC-style JS as well. Let me know if that helps.

            – sfdcfox
            yesterday






          • 2





            That worked. That's really nice, using map and assign to avoid the proxy issues.

            – Renato Oliveira
            yesterday






          • 1





            @RenatoOliveira I am not sure what accepted best practices are, but I too flatten my datatable data. However, I tend to avoid dot notation in flattening just because it's typically associated with JS object properties. You might consider usage of _ in place of .

            – tsalb
            20 hours ago

















          That doesn't seem to work. I get a TypeError: 'set' on proxy: trap returned falsish for property 'Product2.Name' inside the forEach.

          – Renato Oliveira
          yesterday





          That doesn't seem to work. I get a TypeError: 'set' on proxy: trap returned falsish for property 'Product2.Name' inside the forEach.

          – Renato Oliveira
          yesterday













          @RenatoOliveira My aura demo works correctly; let me set up a lwc real quick, I'll be back.

          – sfdcfox
          yesterday





          @RenatoOliveira My aura demo works correctly; let me set up a lwc real quick, I'll be back.

          – sfdcfox
          yesterday




          1




          1





          @RenatoOliveira Network issues, but I came up with a working demo for LWC-style JS as well. Let me know if that helps.

          – sfdcfox
          yesterday





          @RenatoOliveira Network issues, but I came up with a working demo for LWC-style JS as well. Let me know if that helps.

          – sfdcfox
          yesterday




          2




          2





          That worked. That's really nice, using map and assign to avoid the proxy issues.

          – Renato Oliveira
          yesterday





          That worked. That's really nice, using map and assign to avoid the proxy issues.

          – Renato Oliveira
          yesterday




          1




          1





          @RenatoOliveira I am not sure what accepted best practices are, but I too flatten my datatable data. However, I tend to avoid dot notation in flattening just because it's typically associated with JS object properties. You might consider usage of _ in place of .

          – tsalb
          20 hours ago






          @RenatoOliveira I am not sure what accepted best practices are, but I too flatten my datatable data. However, I tend to avoid dot notation in flattening just because it's typically associated with JS object properties. You might consider usage of _ in place of .

          – tsalb
          20 hours ago


















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Salesforce Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f255418%2fis-it-not-possible-to-get-a-parent-field-in-a-datatable-column-specification-fo%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Triangular numbers and gcdProving sum of a set is $0 pmod n$ if $n$ is odd, or $fracn2 pmod n$ if $n$ is even?Is greatest common divisor of two numbers really their smallest linear combination?GCD, LCM RelationshipProve a set of nonnegative integers with greatest common divisor 1 and closed under addition has all but finite many nonnegative integers.all pairs of a and b in an equation containing gcdTriangular Numbers Modulo $k$ - Hit All Values?Understanding the Existence and Uniqueness of the GCDGCD and LCM with logical symbolsThe greatest common divisor of two positive integers less than 100 is equal to 3. Their least common multiple is twelve times one of the integers.Suppose that for all integers $x$, $x|a$ and $x|b$ if and only if $x|c$. Then $c = gcd(a,b)$Which is the gcd of 2 numbers which are multiplied and the result is 600000?

          Barbados Ynhâld Skiednis | Geografy | Demografy | Navigaasjemenu

          Σερβία Πίνακας περιεχομένων Γεωγραφία | Ιστορία | Πολιτική | Δημογραφία | Οικονομία | Τουρισμός | Εκπαίδευση και επιστήμη | Πολιτισμός | Δείτε επίσης | Παραπομπές | Εξωτερικοί σύνδεσμοι | Μενού πλοήγησης43°49′00″N 21°08′00″E / 43.8167°N 21.1333°E / 43.8167; 21.133344°49′14″N 20°27′44″E / 44.8206°N 20.4622°E / 44.8206; 20.4622 (Βελιγράδι)Επίσημη εκτίμηση«Σερβία»«Human Development Report 2018»Παγκόσμιος Οργανισμός Υγείας, Προσδόκιμο ζωής και υγιές προσδόκιμο ζωής, Δεδομένα ανά χώρα2003 statistics2004 statistics2005 statistics2006 statistics2007 statistics2008 statistics2009-2013 statistics2014 statisticsStatistical Yearbook of the Republic of Serbia – Tourism, 20152016 statisticsStatistical Yearbook of the Republic of Serbia – Tourism, 2015Πληροφορίες σχετικά με τη Σερβία και τον πολιτισμό τηςΣερβική ΠροεδρίαΕθνικός Οργανισμός Τουρισμού της ΣερβίαςΣερβική ΕθνοσυνέλευσηΣερβίαεε