Guest User

Untitled

a guest
Nov 15th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. <lightning:datatable
  2. keyField="id"
  3. data="{! v.data }"
  4. columns="{! v.columns }"
  5. hideCheckboxColumn="true"/>
  6.  
  7. <lightning:button variant="brand" label="Add Row" title="Add Row"
  8. onclick="{! c.addRow }" />
  9.  
  10. addRow : function (cmp, event, helper) {
  11.  
  12. // this fetches the existing data as rendered in datatable
  13. var myData = cmp.get("v.data");
  14.  
  15. // now push a new empty row in the array retrieved
  16. myData.push(
  17. {
  18. myfield1: "",
  19. myfield2: ""
  20. }
  21. );
  22.  
  23. // now add the new array back to the attribute, so that it reflects on the component
  24. cmp.set("v.data", myData);
  25. },
Add Comment
Please, Sign In to add comment