Is it not possible to get a parent field in a datatable column specification, for a Lightning Web Component?Retrieve shared data extension column names with SSJS marketing cloudLightning Component works on Sandbox but not on ProductionLightning Web Component for table rows and cellsLightning web component object referenceUnable to set component outside of FileReader().onloadSyntax to dynamically set nested property?Lightning Web Component - Navigation - Show Link in a List / Table to Open RecordHyperlink record name LWC datatablejQuery/DataTable methods in Lightning Web Component - (…).DataTable is not a functionLightning Web Component lightning-datatable and re-render button

How do I calculate the difference in lens reach between a superzoom compact and a DSLR zoom lens?

Yajilin minicubes: the Hullabaloo, the Brouhaha, the Bangarang

Infeasibility in mathematical optimization models

In the movie Harry Potter and the Order or the Phoenix, why didn't Mr. Filch succeed to open the Room of Requirement if it's what he needed?

Acceptable to cut steak before searing?

Do other countries guarantee freedoms that the United States does not have?

What happen if I gain the control of aura that enchants an opponent's creature? Would the aura stay attached?

Colleagues speaking another language and it impacts work

How can you evade tax by getting employment income just in equity, then using this equity as collateral to take out loan?

Shabbat clothing on shabbat chazon

Non-OR journals which regularly publish OR research

How would I as a DM create a smart phone-like spell/device my players could use?

Is refreshing multiple times a test case for web applications?

What method to use in a batch apex in order to get authentication token from a remote server?

Are there any differences in causality between linear and logistic regression?

What is the best way to cause swarm intelligence to be destroyed?

How to say "fit" in Latin?

Evaluate the following limit .

During the Space Shuttle Columbia Disaster of 2003, Why Did The Flight Director Say, "Lock the doors."?

How to write "upright" integrals with automatic sizing

SQL Minimum Row count

Why should public servants be apolitical?

Ex-contractor published company source code and secrets online

Sierpinski turtle triangle



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


Retrieve shared data extension column names with SSJS marketing cloudLightning Component works on Sandbox but not on ProductionLightning Web Component for table rows and cellsLightning web component object referenceUnable to set component outside of FileReader().onloadSyntax to dynamically set nested property?Lightning Web Component - Navigation - Show Link in a List / Table to Open RecordHyperlink record name LWC datatablejQuery/DataTable methods in Lightning Web Component - (…).DataTable is not a functionLightning Web Component lightning-datatable and re-render button






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








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 Mar 26 at 22:33







      Renato Oliveira

















      asked Mar 26 at 22:20









      Renato OliveiraRenato Oliveira

      6,2742 gold badges23 silver badges59 bronze badges




      6,2742 gold badges23 silver badges59 bronze badges























          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
            Mar 26 at 22:39











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

            – sfdcfox
            Mar 26 at 22:41






          • 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
            Mar 26 at 23:14






          • 2





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

            – Renato Oliveira
            Mar 26 at 23:17






          • 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
            Mar 27 at 7:14














          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
            Mar 26 at 22:39











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

            – sfdcfox
            Mar 26 at 22:41






          • 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
            Mar 26 at 23:14






          • 2





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

            – Renato Oliveira
            Mar 26 at 23:17






          • 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
            Mar 27 at 7:14
















          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
            Mar 26 at 22:39











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

            – sfdcfox
            Mar 26 at 22:41






          • 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
            Mar 26 at 23:14






          • 2





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

            – Renato Oliveira
            Mar 26 at 23:17






          • 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
            Mar 27 at 7:14














          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 Mar 26 at 23:14

























          answered Mar 26 at 22:34









          sfdcfoxsfdcfox

          281k14 gold badges230 silver badges482 bronze badges




          281k14 gold badges230 silver badges482 bronze badges















          • 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
            Mar 26 at 22:39











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

            – sfdcfox
            Mar 26 at 22:41






          • 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
            Mar 26 at 23:14






          • 2





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

            – Renato Oliveira
            Mar 26 at 23:17






          • 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
            Mar 27 at 7:14


















          • 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
            Mar 26 at 22:39











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

            – sfdcfox
            Mar 26 at 22:41






          • 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
            Mar 26 at 23:14






          • 2





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

            – Renato Oliveira
            Mar 26 at 23:17






          • 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
            Mar 27 at 7:14

















          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
          Mar 26 at 22:39





          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
          Mar 26 at 22:39













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

          – sfdcfox
          Mar 26 at 22:41





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

          – sfdcfox
          Mar 26 at 22:41




          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
          Mar 26 at 23:14





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

          – sfdcfox
          Mar 26 at 23:14




          2




          2





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

          – Renato Oliveira
          Mar 26 at 23:17





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

          – Renato Oliveira
          Mar 26 at 23:17




          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
          Mar 27 at 7:14






          @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
          Mar 27 at 7:14


















          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

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript