This is a migrated thread and some comments may be shown as answers.

RadListBoxItemCollection client API issue with forEach when using IE 8

4 Answers 144 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
ITDpt
Top achievements
Rank 1
ITDpt asked on 05 May 2010, 04:38 PM
I have the following javascript function for the OnClientTransferred event of a RadListBox. This function works fine with Firefox and Chrome but I get a  javascript error with IE 8.
Here is my javascript.
     <telerik:RadCodeBlock ID="RadCodeBlockMain" runat="server"
<script type="text/javascript"
           function OnClientTransferredHandler(sender, e) { 
               var myitems; 
               var radbox = $find('<%= CurrentlyTransferredValues.ClientId %>'); 
               var radbox2 = $find('<%= SourceListBox.ClientId %>'); 
 
               myitems = e.get_items(); 
               myitems.forEach(function(item) { radbox.set_value(radbox.get_value() + item.get_value() + ","); }); 
               radbox2.set_value(e.get_sourceListBox().get_id()); 
                
           } 
 </script> 
   </telerik:RadCodeBlock> 
The error from IE 8 is the following.
"Microsoft Jscript runtime error: Object doesn't support this property or method"
It seems to fail at line with the forEach statement.

Thanks in Advance



4 Answers, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 07 May 2010, 03:36 PM
Hello Joseph Pasint,

The problem is that there is no property get_value() for the RadListBox client object. Could you please attach the full code or explain me what are you trying to achieve so we can be able to help you?

Thank you!

Kind regards,
Veronica Milcheva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Amy
Top achievements
Rank 1
answered on 04 Feb 2011, 03:32 PM
I have a similar problem in IE8 - my script is as follows:
<telerik:RadScriptBlock runat="server" ID="RadScriptBlockSLA2">
   
            <script id="clientEventHandlersSLA2s" language="javascript" type="text/javascript">
            //<![CDATA[                
                function onSLATransferring(sender, args) {
                    var items = args.get_items();
                    items.forEach(function (itm)  {
                        var checked = itm.get_checked();
                        if (checked) {
                            alert("The default cannot be removed.");
                            args.set_cancel(true);
                            return false;
                        }
                    } );
                }
      //]]>
            </script>  
    
</telerik:RadScriptBlock>

The RadListBox has the following definition:
<rad:RadListBox ID="rlbAssignedSLA" runat="server" Height="250px" Width="200px" SelectionMode="Multiple" CheckBoxes="true" TransferToID="rlbAvailableSLA" OnClientItemChecking="onSLAItemChecking" OnClientTransferring="onSLATransferring" AllowTransfer="true" AllowReorder="false" Skin="WebBlue"  ButtonSettings-ShowTransferAll="false" AutoPostBackOnTransfer="false" AutoPostBackOnReorder="false" EnableDragAndDrop="true" AllowTransferOnDoubleClick="true" PersistClientChanges="true"  >
</rad:RadListBox>

As far as I know, all the methods used within the forEach are valid for a RadListBoxItem.
0
Evgeny Grigoryev
Top achievements
Rank 1
answered on 27 Jul 2011, 12:28 PM
Bump!!!
I have a similar problem in IE7 - my script is as follows:
It seems to fail at line with the forEach statement.

<telerik:RadCodeBlock  runat="server" ID="RadCodeBlock1">
             <script type="text/javascript">
                function pageLoad() {
                    window.$ = $telerik.$;
                    var listBox = $find("PhotoGalleryListBox");
                    var button = $("<button id='addSelectedImages' type='button' title='Add selected files'>Add selections</button>")
                        .prependTo($("div:first", listBox.get_element()));
                         
                    $("#addSelectedImages").click(function(e) {
                        var selectedItems = $find("RadFileExplorer1").get_selectedItems(); // Retrieve the selected items ; 
                        var listbox = $find("PhotoGalleryListBox").get_items();
                        var extension = "jpg,gif,png"
                        selectedItems.forEach(function(item) {
                            if (extension.indexOf(item.get_extension().toLowerCase())>-1){
                                var RadListBoxItem = new Telerik.Web.UI.RadListBoxItem();
                                    RadListBoxItem.set_text(item.get_name());
                                RadListBoxItem.set_imageUrl(item.get_url());
                                listbox.add(RadListBoxItem);
                                RadListBoxItem.select();
                                RadListBoxItem.scrollIntoView();
                            }
                        });
                    });
            }
 
        </script>
 
    </telerik:RadCodeBlock>
0
Dimitar Terziev
Telerik team
answered on 29 Jul 2011, 01:54 PM
Hi Evgeny,

The reason for the experienced behavior is due to the fact that some browsers do not support forEach by default.

Please refer to the following forum thread discussing this issue here and here.

Best wishes,
Dimitar Terziev
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
ListBox
Asked by
ITDpt
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Amy
Top achievements
Rank 1
Evgeny Grigoryev
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Share this question
or