f.getItem(...) is null or not an object

8 posts, 0 answers
  1. tlp
    tlp avatar
    33 posts
    Member since:
    Oct 2006

    Posted 03 Sep 2009 Link to this post


    I'm trying to manually transfer list items on the client side and received the script error 'f.getItem(...)' is null or not an object when the following method is called:

     

    sender.transferItem(item, e.get_sourceListBox(), e.get_destinationListBox());

    Basically, the aspx page has a source and destination listbox. The source listbox is pre-populated in the code behind with a list of approximately 10 items. The error occurs when a transfer is performed from the source to the destination listbox or from the destination to the source listbox.

    The code for the JavaScript function that is called by the source listbox for the OnCLientTransferring event is as follows:

     

    1 function RadListBoxColumnSource_OnClientTransferring(sender, e)  
    2             {  
    3                   
    4                 // Cancel the transfer so that can validate which items can be transferred.  
    5                 e.set_cancel(true);  
    6                   
    7                 // Manually transfer items that are not formula items.  
    8                 var items = e.get_items();  
    9                                                   
    10                 for (var i = 0; i < items.length; i++)  
    11                 {  
    12                     var item = items[i];  
    13                       
    14                     // If the tooltip information is available then the item is a formula.  
    15                     var toolTip = item.get_toolTip();  
    16                     if ((toolTip == null) || (toolTip.length() == 0))  
    17                     {  
    18                         sender.transferItem(item, e.get_sourceListBox(), e.get_destinationListBox());  
    19                     }  
    20                 }  
    21                   
    22                 return;  
    23             } 

    The code snippet for the listboxes in the aspx page is as follows:

    1 <table style="font-size: 0.7em; font-family: Verdana" width="500px">  
    2             <tr> 
    3                 <td> 
    4                     <asp:Panel ID="PanelSource" runat="server" GroupingText="Data Columns" Width="100%">  
    5                         <telerik:RadListBox ID="RadListBoxColumnSource" runat="server" AllowReorder="false" AllowTransfer="true" EnableDragAndDrop="true" SelectionMode="Multiple" TransferToID="RadListBoxColumnTarget" Width="220px" Height="400px" OnClientTransferring="RadListBoxColumnSource_OnClientTransferring" > 
    6                             <ButtonSettings ShowTransferAll="true" /> 
    7                         </telerik:RadListBox> 
    8                     </asp:Panel> 
    9                 </td> 
    10                 <td> 
    11                     <asp:Panel ID="PanelTarget" runat="server" GroupingText="Selected Data Columns" Width="100%">  
    12                         <telerik:RadListBox ID="RadListBoxColumnTarget" runat="server" AllowReorder="true" EnableDragAndDrop="true" SelectionMode="Multiple" Width="220px" Height="400px" > 
    13                             <ButtonSettings ShowReorder="true" />                          
    14                         </telerik:RadListBox> 
    15                     </asp:Panel> 
    16                 </td> 
    17             </tr> 
    18         </table> 

    The browser version is Internet Explorer 8.0.6001.18702 and the version of the Telerik controls are 2009.2.826.

    Any help in resolving this issue is appreciated.



    Thanks,

    Tony

  2. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 03 Sep 2009 Link to this post

    Does this occur in every iteration of your for loop? And does the behavior change when you have multiple items to transfer over?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. tlp
    tlp avatar
    33 posts
    Member since:
    Oct 2006

    Posted 03 Sep 2009 Link to this post

    The behaviour is a bit strange. The problem is consistently reproduced if the last item in the source (or destination) listbox is selected for the transfer. If all items are transferred, the issue does not occur. If multiple items are selected (excluding the last item in the list), the issue does not always occur.


    Tony




  5. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 03 Sep 2009 Link to this post

    So it would seem that the control is trying always grab the item after the selection, so if you have X items and you grab X-1 it does something with the last remaining item, but when you drag all of them (or the last one) it tries to go to the next item which is null. What I can think of off the top of my head is that it might be trying to highlight or interact with the next item.

    If you transfer an item away does the item after it become highlighted/selected?
  6. tlp
    tlp avatar
    33 posts
    Member since:
    Oct 2006

    Posted 03 Sep 2009 Link to this post

    Yes, you are correct. It seems that it is trying to highlight the item following the transferred item. When an item is transferred (prior to the last item in the list), the item following the transferred item is being highlighted. This would indicate that f.getItem(...) is trying to find an item to highlight (or interact with) and is returning null since no items exist after the last item - thus the exception.

    The problem is that the error is being thrown in Telerik.Web.UI.WebResource.axd and therefore is an issue with the ListBox control.

    A workaround would be to ensure that an empty item (which is disabled) always exists at the bottom of the list. I tried this as a sample and it seems to work. Although, if the last enabled item in the list is transferred, the empty item is partially highlighted.



    Thanks for the insight,

    Tony

  7. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 09 Sep 2009 Link to this post

    Hello guys,

    This is bug in the RadListBox. As you have properly concluded, after the event is canceled, RadListBox tries to restore the selection as it was. However, the items are no longer there, hence the null reference come. The good news are that we have fixed the problem and the patch is going to be available forth from the tomorrow's internal build. More information on how to obtain the internal build can be  found here.

    Regards,
    Genady Sergeev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. Yuvika
    Yuvika avatar
    36 posts
    Member since:
    Mar 2009

    Posted 20 Apr 2010 Link to this post

    Hi,

    Please provide the work around for it.
    How can I resolve this issue.

    Thanks,
    Yuvika
  9. tlp
    tlp avatar
    33 posts
    Member since:
    Oct 2006

    Posted 20 Apr 2010 Link to this post

    Yuvika,

    As it was stated in one of the previous post, the issue was resolved when I upgraded my version of RadControls. I'm currently using v2009.3.1314.20 and no longer experience the issue.

    Also, as indicated in one of the previous posts, a potential workaround would be to ensure that an empty item (which is disabled) always exists at the bottom of the list. This is not the best workaround but it will solve your issue if you are having the problem.


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