RadListBoxItemCollection client API issue with forEach when using IE 8

5 posts, 0 answers
  1. ITDpt
    ITDpt avatar
    5 posts
    Member since:
    Sep 2008

    Posted 05 May 2010 Link to this post

    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



  2. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 07 May 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Amy
    Amy avatar
    1 posts
    Member since:
    Sep 2010

    Posted 04 Feb 2011 Link to this post

    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.
  5. Evgeny Grigoryev
    Evgeny Grigoryev avatar
    10 posts
    Member since:
    Apr 2010

    Posted 27 Jul 2011 Link to this post

    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>
  6. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 29 Jul 2011 Link to this post

    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.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017