Is it possible to achieve something similar with standard salesforce or is it completely custom?
It has to be a custom component.
If it is a completely custom function what is the best approach for doing something similar?
You can utilize lightning:datatable here. A very basic example here as how you can achieve this is below. You will need to go through further details on the component and how to handle different scenarios, but this should provide you a starting point.
In your component while utilizing a datatable
, declare a button say Add Row
:
<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 }" />
And in the JS controller for addRow
, have something as:
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);
},
In your code, you are setting the page reference as follows:
PageReference pageRef = new PageReference('/'+ppConfigObj.getKeyPrefix()+'/e?retURL='+url);
In particular, you are calling a method ppConfigObj.getKeyPrefix()
that looks as though you're getting the object name or something from a map. It's not exactly clear what it is since you don't show that part of your code. For all I know it could be the full path to the page like: /Apex/thisVisualForcePageName
.
I think what you want to be doing is one of two things. Either converting that button to an Action (the action would work the same in Lightning) or convert the link to the proper format that Lightning expects it to have; one that includes the Object Name. When constructing the button link, I think you probably want to do something like the following:
{!URLFOR( $Action.Case.NewCase, $ObjectType.Case )}
See Constructing Effective Custom URL Buttons and Links in the Salesforce Documentation for more on this subject with additional details and considerations that might apply to your situation.
Best Answer
If i understood correctly, you want to open this popup in a custom component or a button/url. If so, you can try using force:createRecord.
You can check this link for more: force:createRecord or createRecord Documentation