5 Replies Latest reply: Jan 14, 2014 9:26 AM by Joe R RSS

    possible bug in apex.item( pNd ).setValue(pValue, pDisplayValue, pSuppressChangeEvent)

    slothmanJim


      In the documentation http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35127/javascript_api.htm#BGBBCDCH it states that pValue could be a string or an array.  When i pass an array in as pValue the multiselect does not get set.  in looking at the code in apex_4_1.js appx line 431 it does not handle an array only a string.

       

       

      for(var i=0,len=lOpts.length;i<len;i++){
               var lCheck = (lOpts[i].value==pValue)?true:false;
               if(that.item_type == 'RADIO_GROUP' || that.item_type == 'CHECKBOX_GROUP'){
                lOpts[i].checked=lCheck;
               }else{
                lOpts[i].selected=lCheck;
               }
              }
      
      
        • 1. Re: possible bug in apex.item( pNd ).setValue(pValue, pDisplayValue, pSuppressChangeEvent)
          Joni Vandenberghe

          Looks like the documentation is pretty clear about that one.

           

          The value to be set. For items that support multiple values (for example a 'Shuttle'), an array of string values can be passed to set multiple values at once.

          So the array IS a string, so you can't actually pass a javascript array only a string where the values are seperated by a ':' such as the return of a shuttle item

           

          Regards,

          Joni

          • 2. Re: possible bug in apex.item( pNd ).setValue(pValue, pDisplayValue, pSuppressChangeEvent)
            slothmanJim

            Thanks for the response.  When i think of an "array of string values" i think of

             

            var pValue=["A","B","C"];
            

            not a colon separated list of values

             

            I tried what you suggested by making pValue a colon separated string and it still is not setting the values

             

             

            var pValue ='A:B:C';
            setTimeout(function(){
            $("#P145_FAMILY").focus();
            $s("P145_FAMILY",pValue);
            $("#P145_FAMILY").change();
            console.log("done");
            },1500);
            
            

             

            If i set pValue to be a single string value "A".  then it sets the value.

            Would you happen to have a working example?  I am using Apex 4.1.1

            Thanks

            • 3. Re: possible bug in apex.item( pNd ).setValue(pValue, pDisplayValue, pSuppressChangeEvent)
              Joni Vandenberghe

              You are asking for information on the apex.item framework, and instead you use the old deprecated function $s. I am confused.

              An example of code using the correct javascript function would be:

              apex.item('P145_FAMILY').setValue('2:6');

               

              Where 2 and 6 are the return values defined in a checkbox or radiogroup.

              • 4. Re: possible bug in apex.item( pNd ).setValue(pValue, pDisplayValue, pSuppressChangeEvent)
                slothmanJim

                I tried it both ways

                apex.item("P145_FAMILY").setValue(pValue);
                

                and

                 

                 

                $s("P145_FAMILY",pValue);
                

                 

                neither work.  I am trying to set the values of a multi-select and maybe this functionality does not work for a multi-select

                 

                Thanks for your time

                • 5. Re: possible bug in apex.item( pNd ).setValue(pValue, pDisplayValue, pSuppressChangeEvent)
                  Joe R

                  Hello,

                   

                  It looks like the apex.item( pNd ).setValue(pValue, pDisplayValue, pSuppressChangeEvent) is in 4.2 and $s(pNd, pValue, pDisplayValue, pSuppressChangeEvent) is in 4.1. I don't see any mention of apex.item( pNd ).setValue(pValue, pDisplayValue, pSuppressChangeEvent) in the 4.1 docs. I could be wrong.

                  In the 4.1 docs: http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/javascript_api.htm#CHDFBJGD

                   

                  $s(pNd, pValue, pDisplayValue, pSuppressChangeEvent)

                   

                  Given a DOM node or string ID (pNd), this function sets the Application Express item

                  value taking into account the item type. The pDisplayValue is optional. If used for a

                  page item of type "Popup LOV" where the attribute "Input Field" = "Not Enterable,

                  Show Display Value and Store Return Value", it is used to set the "Input Field". The

                  value of pValue will be stored in the hidden return field. The

                  pSuppressChangeEvent parameter is optional. Passing either FALSE or not passing

                  this parameter value results in a change event firing for the item being set. Pass TRUE

                  to prevent the change event from firing for the item being set.

                   

                  Parameters

                  pNd                                    (DOM Node | string ID)

                  pValue                               (String | Array)

                  pDisplayValue                    (String)

                  pSuppressChangeEvent     (Boolean)

                   

                  In the 4.2 docs: http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35127/javascript_api.htm#autoId11

                   

                  apex.item( pNd ).setValue(pValue, pDisplayValue, pSuppressChangeEvent)

                   

                  Sets the Application Express item value, taking into account the item type. This

                   

                  function sets the current value of an Application Express item on the page, not the

                   

                  item's current value in session state. It also allows for the caller to suppress the

                   

                  'change' event for the item being set, if desired.

                   

                  See the

                   

                   

                  $s( pNd, pValue, pDisplayValue, pSuppressChangeEvent )

                   

                   

                  function for a shortcut to

                   

                  .setValue()

                  .

                   

                   

                  Thanks,

                  Joe