1

VF Page:

<apex:page standardController="Account" tabstyle="account" sidebar="false" extensions="testpagec">
<apex:form >
<apex:includeLightning />
<div id="lightning"/>
<apex:pageBlock >
<apex:pageBlockTable value="{!accList}" var="a" id="list">
<apex:column value="{!a.Id}" />
<apex:column value="{!a.name}"/>
<apex:column >
    <script>
        $Lightning.use("c:testpage", function() {
          $Lightning.createComponent("c:buttoncomp",
          {},
          "lightning",
          function(cmp) {
            // do some stuff
          });
        });
    </script>
    <br/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>    
</apex:form>
</apex:page>

Lightning component:

<aura:component >
<ui:button aura:id="DelButton" label="Delete" />
</aura:component>
<aura:application access="GLOBAL" extends="ltng:outApp"> 
 <aura:dependency resource="c:buttoncomp"/>
</aura:application>

In the vf page i am listing account and in the lightning compoent i have created a button i need to expose the button on each record column in vf page. Now based on recordlist all the button are listed in the top of page rather than in the column kinldy help me to fix it.

1

In lightning out you specify where the lightning component is injected via Id parameter .In your case you have given Id of the div above .So lets give your apex:column an Id and try injecting there

<apex:column id="blk">
<script>
    $Lightning.use("c:testpage", function() {
      $Lightning.createComponent("c:buttoncomp",
      {},
      "{!$Component.blk}",
      function(cmp) {
        // do some stuff
      });
    });
</script>
<br/>

Check the screenshot below and seems fine in my dev org

enter image description here

| improve this answer | |
  • 1
    Nicely done - makes me extremely happy to see more and more non trivial questions being answered by the Lightning community - keep up the excellent work! – Doug Chasman Jan 14 '16 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.