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

RadListbox : Undefined is null or not an object onclick when no items

1 Answer 134 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
rei
Top achievements
Rank 1
rei asked on 04 Dec 2009, 02:41 AM
Hi,

I have a listbox  that I am populating client side from a list of items that users entered. Initially there are no listbox items, but I set the height of the listbox to 200px. When I click inside the listbox when there are still no items , it displays a  javascript error 'undefined' is null or not an object.  I believe it happens on the _activateItem client side event  of the listbox, but Im not sure how to disable it when there are no items in the list.

Is there a way to trap the _activeitem event on client side or disable it when the list of items = 0 ?

Thanks,
rei

1 Answer, 1 is accepted

Sort by
0
Accepted
Genady Sergeev
Telerik team
answered on 04 Dec 2009, 08:46 AM
Hello rei,

This is a known issue with the RadListBox. We have already fixed it, you can check up on the latest internal build. If you cannot update to the latest internal you can use the following work around, please paste it right after your script manager declaration:

Telerik.Web.UI.RadListBox.prototype._onFocus = function(e) {
          if (this._activeItem) {
              $(this._activeItem.get_element()).addClass("rlbActive");
              return;
          }
  
          var item = this.get_selectedItem();
          if (item) {
              this._activateItem(item, true);
              return;
          }
  
          item = this._getFirstVisibleItem()
          if (item) {
              this._activateItem(item);
              return;
          }
      }


All the best,
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.
Tags
ListBox
Asked by
rei
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Share this question
or