[SalesForce] Lightning DataTable Component Issues in SF1 — and other idiosyncrasies not mentioned in the docs

I have just implemented the Winter '18 Lightning DataTable Component in a project set to go live early next year. I have a love hate relationship with this base component here are my issues, and I am answering this question with my findings in hopes it will save others some head-aching.

  1. Why does the header row behave weirdly in SF1? You won't see this in the Chrome emulator but fire up the app in your IPad for some odd behavior.

  2. Why no input elements? Read-only sadness.

  3. I got lost in sort… the documentation failed me here completely and I had to dissect the component behavior to understand how to fix it. Sort just didn't work initially. The docs are confusing on where to set the attributes… i.e. at the component level or the data column level.

  4. Setting column initial, min and max sizing at the data level as the docs suggest made the resizing of columns break.

  5. Wasn't getting the click row data initially.

Best Answer

  1. In SF1 the header row behaves really strangely, it disappears when you scroll, and reappears sometimes only in part when you tap on it. 1a. I logged a case with SFDC and eventually was told the problem is that DataTables are using LDS which isn't supported in SF1. I think this is a bogus answer as I have constructed my own tables using LDS which work swimmingly in SF1.

  2. No Input element yet, this is in the docs but it is a serious agro.

  3. The sort function needs some tweaking to work properly. If you copy the documented code you will find it does not work correctly. I added an attribute for SortedDirection and set the default to Desc as well as an attribute for the sortedBy. See below:

    <aura:attribute name="sortedBy" type="String" />`
    
    <aura:attribute name="sortedDirection" type="String" default="Desc"/>`
    

    3a. Sort is still a little weird after this as there seems to be a dependency on between the columns, for example, once you sort by name if you sort by age the age sort will be sub sorted within the alpha sort of name. It might be better to roll your own sort function if you want sorting on multiple columns.

  4. Don't set the initial width, min and max width of the columns because you will get wacky results with dynamic data and the column resizing won't behave properly.

  5. Checkboxes are a little wonky but once you get used to their special logic they make sense mostly... don't add an onclick handler as the onrowselection handler does the lifting here.