Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <lightning:datatable
- keyField="id"
- data="{! v.data }"
- columns="{! v.columns }"
- hideCheckboxColumn="true"/>
- <lightning:button variant="brand" label="Add Row" title="Add Row"
- onclick="{! c.addRow }" />
- addRow : function (cmp, event, helper) {
- // this fetches the existing data as rendered in datatable
- var myData = cmp.get("v.data");
- // now push a new empty row in the array retrieved
- myData.push(
- {
- myfield1: "",
- myfield2: ""
- }
- );
- // now add the new array back to the attribute, so that it reflects on the component
- cmp.set("v.data", myData);
- },
Add Comment
Please, Sign In to add comment