• Eric Clay!
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies

In my pageBlockTable, when the "Quantity" is changed, it would be a action and reRender this table,

when the table is rerenderd, the focus in this table would be lost, so i'm trying to re-focus the last element.

here is my code:

<apex:page controller="Mycontroller">
<script type="text/javascript">
   var elementFocus = null;
   function setFocus(){
       elementFocus = document.activeElement;
   }
   function retainFocus(){
       elementFocus.focus();
   }
</script>
 <apex:form >
   <apex:pageBlock>
      <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
         <apex:column headerValue="Quantity">
             <apex:inputField value="{!wrapper.sub.Quantity__c}" id="Quantity__c">
                 <apex:actionSupport event="onchange" action="{!doSomething}"

                     <!-- before take action, set current focus. oncomplete, retain that focus -->
                     onbeforedomupdate="return setFocus()" rerender="wtable" oncomplete="return retainFocus()">
                 </apex:actionSupport>
             </apex:inputField>
         </apex:column>
         <apex:column headerValue="SalesPrice">
            <apex:inputField value="{!wrapper.sub.SalesPrice__c}" id="SalesPrice__c"/>
         </apex:column>
      </apex:pageBlockTable>
   </apex:pageBlock>
 </apex:form>
</apex:page>

 i use javascript to retain focus, and the alert also shows the right id, but elementFocus.focus(); just don't work.

should i include some other script?

<script type="text/javascript">
   var elementFocus = null;
   function setFocus(){
       elementFocus = document.activeElement;
       alert(elementFocus.id);
   }
   function retainFocus(){
       alert(elementFocus.id); //when debug, it shows the same value as the id in setFocus()
elementFocus.focus(); } </script>

 Any help would be much appreciated!

I want to concatenate two object IDs in order to make a hash value for a map, but this doesn't work:

 

conversionMap.put(entry.Pricebook2Id + entry.Product2Id), entry);

If I could convert the IDs to strings first, then I should be able to concatenate them in this way.  But, while there is a function to convert a string to an ID, I can't find any way to convert an ID to a string.  Anybody know how to do that?  Or, a better way to do what I'm trying to do?

 

Hi

 

I tried to make the visualforce page renderas PDF in landscape with following styles

 

<style >
    @page {
        size:landscape;
   }
 </style>
 

 

But it is not working now. Is anybody face the same issue? or have any idea to render the PDF as landscape??

 

Thanks!

  • August 18, 2009
  • Like
  • 0