0

When attempting to sort a lightning datatable, the error 'NoErrorObjectAvailable' pops up.

HTML:

       key-field="Id"
       data={jobItems}
       columns={columns}
       hide-checkbox-column
       onrowaction={handleRowAction}
       onsort={updateColumnSorting}
   ></lightning-datatable>```

JS:
updateColumnSorting(event)
{          
   var fieldName = event.detail.fieldName;
   var sortDirection = event.detail.sortDirection;

   console.log('## fieldName: ' + fieldName);
   console.log('## sortDirection: ' + sortDirection);
            
}```

ERROR:

[NoErrorObjectAvailable] Script error. a()@https://static.lightning.force.com/cs70/auraFW/javascript/7p9HLMpgnV2GO9Mq/aura_prod.js:948:169 {anonymous}()@https://static.lightning.force.com/cs70/auraFW/javascript/7p9HLMpgnV2GO9Mq/aura_prod.js:948:362 ln.dispatchEvent()@https://static.lightning.force.com/cs70/auraFW/javascript/7p9HLMpgnV2GO9Mq/aura_prod.js:12:12146 ln.fireSortedColumnChange()@https://COMPANY_NAME--SANDBOX_NAME.lightning.force.com/components/lightning/datatable.js:2:66247 ln.handleUpdateColumnSort()@https://COMPANY_NAME--SANDBOX_NAME.lightning.force.com/components/lightning/datatable.js:2:65875```

Dima
  • 21
  • 1
  • 4

2 Answers2

0

I encountered a similar issue today when trying to dispatch a custom event from a lightning-combobox's onchange handler. What helped me to get rid of the error was to change var into const.

Doesn't work

 handleSearchOptionChange(event) {
      console.log(event.detail, event.detail.value);
      this.selectedBoatTypeId = event.detail.value;

      var searchEvent = new CustomEvent('search', { detail:{ boatTypeId: event.detail.value }});
      this.dispatchEvent(searchEvent);
 }

Working

 handleSearchOptionChange(event) {
      console.log(event.detail, event.detail.value);
      this.selectedBoatTypeId = event.detail.value;

      const searchEvent = new CustomEvent('search', { detail:{ boatTypeId: event.detail.value }});
      this.dispatchEvent(searchEvent);
 }

Not sure if it's the same in your particular case, but wanted to share it since it costed me about 45 minutes of debugging...

0

Found the issue. The mistake was putting on sort function inside another function by mistake in VS Code. It was saving just fine with proper highlighting and all. It only errored out when I tried to write a getter function right after it.

Dima
  • 21
  • 1
  • 4