Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

What were all sort primed in the lightning-datatable sort example?

Asked by Aalap Prabhakaran Jun 1, 2023 896 views 1 answer
Share

About this question

 The example "Datatable with Sortable Column" (from the lightning-datatable documentation) includes this code where a primer parameter is declared and used in the sortBy function:


sortBy(field, reverse, primer) { const key = primer ? function (x) { return primer(x[field]); } : function (x) { return x[field]; }; return function (a, b) { a = key(a); b = key(b); return reverse * ((a > b) - (b > a)); }; } onHandleSort(event) { const { fieldName: sortedBy, sortDirection } = event.detail; const cloneData = [...this.data]; cloneData.sort(this.sortBy(sortedBy, sortDirection === 'asc' ? 1 : -1)); this.data = cloneData; this.sortDirection = sortDirection; this.sortedBy = sortedBy; }

In a quick test, it is always undefined. What is its purpose, when is it populated and where is it documented?


Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.