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

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

7 Answers 142 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
tlp
Top achievements
Rank 1
tlp asked on 03 Sep 2009, 02:33 PM

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:

 

function RadListBoxColumnSource_OnClientTransferring(sender, e)  
            {  
                  
                // Cancel the transfer so that can validate which items can be transferred.  
                e.set_cancel(true);  
                  
                // Manually transfer items that are not formula items.  
                var items = e.get_items();  
                                                  
                for (var i = 0; i < items.length; i++)  
                {  
                    var item = items[i];  
                      
                    // If the tooltip information is available then the item is a formula.  
                    var toolTip = item.get_toolTip();  
                    if ((toolTip == null) || (toolTip.length() == 0))  
                    {  
                        sender.transferItem(item, e.get_sourceListBox(), e.get_destinationListBox());  
                    }  
                }  
                  
                return;  
            } 

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

<table style="font-size: 0.7em; font-family: Verdana" width="500px">  
            <tr> 
                <td> 
                    <asp:Panel ID="PanelSource" runat="server" GroupingText="Data Columns" Width="100%">  
                        <telerik:RadListBox ID="RadListBoxColumnSource" runat="server" AllowReorder="false" AllowTransfer="true" EnableDragAndDrop="true" SelectionMode="Multiple" TransferToID="RadListBoxColumnTarget" Width="220px" Height="400px" OnClientTransferring="RadListBoxColumnSource_OnClientTransferring" > 
                            <ButtonSettings ShowTransferAll="true" /> 
                        </telerik:RadListBox> 
                    </asp:Panel> 
                </td> 
                <td> 
                    <asp:Panel ID="PanelTarget" runat="server" GroupingText="Selected Data Columns" Width="100%">  
                        <telerik:RadListBox ID="RadListBoxColumnTarget" runat="server" AllowReorder="true" EnableDragAndDrop="true" SelectionMode="Multiple" Width="220px" Height="400px" > 
                            <ButtonSettings ShowReorder="true" />                          
                        </telerik:RadListBox> 
                    </asp:Panel> 
                </td> 
            </tr> 
        </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

7 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 03 Sep 2009, 04:28 PM
Does this occur in every iteration of your for loop? And does the behavior change when you have multiple items to transfer over?
0
tlp
Top achievements
Rank 1
answered on 03 Sep 2009, 04:44 PM
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




0
Schlurk
Top achievements
Rank 2
answered on 03 Sep 2009, 08:11 PM
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?
0
tlp
Top achievements
Rank 1
answered on 03 Sep 2009, 08:40 PM
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

0
Genady Sergeev
Telerik team
answered on 09 Sep 2009, 10:27 AM
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.
0
Yuvika
Top achievements
Rank 1
answered on 20 Apr 2010, 12:05 PM
Hi,

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

Thanks,
Yuvika
0
tlp
Top achievements
Rank 1
answered on 20 Apr 2010, 02:24 PM
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
Tags
ListBox
Asked by
tlp
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
tlp
Top achievements
Rank 1
Genady Sergeev
Telerik team
Yuvika
Top achievements
Rank 1
Share this question
or