function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
KevlangdoKevlangdo 

pageblocktable onrowclick

Can someone tell me why I am getting an unknown property accounts.SFDC_Account_Name__c when I pass this field as a parameter to the JS function

Save error: Unknown property 'DataIntegrityList.accounts'    
I am completely baffled as there are many examples in the forum and the web depicting this same pattern.

 
<apex:form >
		   <apex:pageBlock title="Account Data Integrity Issues List">
		      <apex:pageBlockTable value="{!accountProblemsList}" var="accounts" onRowClick="rowSelected('{!accounts.SFDC_Account_Name__c}')">
		      	
		         <apex:column value="{!accounts.PW_Account_Number_SFDC__c}"/>
		         <apex:column value="{!accounts.PW_Account_Number__c}"/>
		        
		         <apex:column value="{!accounts.SFDC_Account_Name__c}"/>
		         <apex:column value="{!accounts.SFDC_ID_PW__c}"/>        
		         <apex:column value="{!accounts.PW_Rep__c}"/>   
		         <apex:column value="{!accounts.SFDC_rep__c}"/>
		         <apex:column value="{!accounts.SFDC_repid__c}"/>
		         <apex:column value="{!accounts.PW_Acct_Status__c}"/>         
		      </apex:pageBlockTable>
		   </apex:pageBlock>
   	</apex:form>

 
Best Answer chosen by Kevlangdo
Balayesu ChilakalapudiBalayesu Chilakalapudi
You can't reference the variable until it is already inside the table.
Pass this pointer to your JS function and access the element with DOM like this.
<apex:form >
        <script type="text/javascript">
     function rowSelected(v){
         alert('val:'+v.textContent);
         }
    </script>
		   <apex:pageBlock title="Account Data Integrity Issues List">
		      <apex:pageBlockTable value="{!accountProblemsList}" var="accounts" onRowClick="rowSelected(this)">
		      	
		         <apex:column value="{!accounts.PW_Account_Number_SFDC__c}"/>
		         <apex:column value="{!accounts.PW_Account_Number__c}"/>
		        
		         <apex:column value="{!accounts.SFDC_Account_Name__c}"/>
		         <apex:column value="{!accounts.SFDC_ID_PW__c}"/>        
		         <apex:column value="{!accounts.PW_Rep__c}"/>   
		         <apex:column value="{!accounts.SFDC_rep__c}"/>
		         <apex:column value="{!accounts.SFDC_repid__c}"/>
		         <apex:column value="{!accounts.PW_Acct_Status__c}"/>         
		      </apex:pageBlockTable>
		   </apex:pageBlock>
   	</apex:form>

All Answers

Vinuthh SVinuthh S
Hi Kevin

Can you please post all the code including the JS.


Thanks
Vinuthh S
Balayesu ChilakalapudiBalayesu Chilakalapudi
You can't reference the variable until it is already inside the table.
Pass this pointer to your JS function and access the element with DOM like this.
<apex:form >
        <script type="text/javascript">
     function rowSelected(v){
         alert('val:'+v.textContent);
         }
    </script>
		   <apex:pageBlock title="Account Data Integrity Issues List">
		      <apex:pageBlockTable value="{!accountProblemsList}" var="accounts" onRowClick="rowSelected(this)">
		      	
		         <apex:column value="{!accounts.PW_Account_Number_SFDC__c}"/>
		         <apex:column value="{!accounts.PW_Account_Number__c}"/>
		        
		         <apex:column value="{!accounts.SFDC_Account_Name__c}"/>
		         <apex:column value="{!accounts.SFDC_ID_PW__c}"/>        
		         <apex:column value="{!accounts.PW_Rep__c}"/>   
		         <apex:column value="{!accounts.SFDC_rep__c}"/>
		         <apex:column value="{!accounts.SFDC_repid__c}"/>
		         <apex:column value="{!accounts.PW_Acct_Status__c}"/>         
		      </apex:pageBlockTable>
		   </apex:pageBlock>
   	</apex:form>
This was selected as the best answer
KevlangdoKevlangdo
<apex:page controller="DataIntegrityList">
<apex:includeScript value="{!URLFOR($Resource.jquery300,'/jquery-3.0.0.min.js')}" />
<apex:includeScript value="{!URLFOR($Resource.jquery300,'/jquery-3.0.0.min.js')}" />
<style type="text/css">
        h1 { font-weight: 24pt; }
        h2 { font-weight: 18pt;}
    </style>
    <script>
    	function rowSelected(r){
    	
    		alert(r);
    	}
    	
    	
		
		
    </script>
    
<h1>Data Integrity Portal</h1><br/>
	<apex:form >
		   <apex:pageBlock title="Account Data Integrity Issues List" id="tblblock">
		      <apex:pageBlockTable id="accts" value="{!accountProblemsList}" var="accounts" onRowClick="rowSelected(document.getElementById('{!$Component.form.tblblock.accts.Name}').value)">
		      	
		         <apex:column value="{!accounts.PW_Account_Number_SFDC__c}"/>
		         <apex:column value="{!accounts.PW_Account_Number__c}"/>
		        
		         <apex:column value="{!accounts.SFDC_Account_Name__c}" id="Name"/>
		         <apex:column value="{!accounts.SFDC_ID_PW__c}"/>        
		         <apex:column value="{!accounts.PW_Rep__c}"/>   
		         <apex:column value="{!accounts.SFDC_rep__c}"/>
		         <apex:column value="{!accounts.SFDC_repid__c}"/>
		         <apex:column value="{!accounts.PW_Acct_Status__c}"/>         
		      </apex:pageBlockTable>
		   </apex:pageBlock>
   	</apex:form>
</apex:page>
 
public with sharing class DataIntegrityList {
        private final Account account;
        public list<AccountDataIntegrity__c> accountProblemsList {get; set;}
        
        public DataIntegrityList(){
                accountProblemsList = [select  PW_Account_Number_SFDC__c, PW_Account_Number__c,name, PW_Rep__c, SFDC_Account_Name__c, SFDC_ID_PW__c, SFDC_rep__c, SFDC_repid__c, PW_Acct_Status__c from AccountDataIntegrity__c];
        }
        public PageReference searchCustomer(){
                List<Account> accts;
                PageReference acctPage;
                try{
                         accts = [Select casesafeid__c, name, quasimodo_id__c from Account where name like :ApexPages.currentPage().getParameters().get('SFDC_Account_Name__c')];
                         acctPage = new ApexPages.StandardController(accts[0]).view();
                }catch(Exception e){
                        ApexPages.addMessages(e);
                }
                acctPage.setRedirect(true);
                return acctPage;
        }
    
}

Hope this helps. thanks

Kevin
KevlangdoKevlangdo
Hi Balayesu,
This works. Thanks. However it returns the whole row as a string. If I try and convert to an array I get not output
 
function rowSelected(r){
           // var array = JSON.parse("[" + r.textContent + "]");
           // alert(array.split()[1]);
            alert(r.textContent);
        }

 
KevlangdoKevlangdo
This paetially works but the split doesn't occur at the right place
alert(r.textContent.split(" ")[0]);

 
Balayesu ChilakalapudiBalayesu Chilakalapudi
This should work
function rowSelected(r){
     alert('val:'+r.cells[2].firstChild.innerHTML);
}
KevlangdoKevlangdo
Thanks Balayesu. That is perfact!