Using ComboBox Events

Combobox events can be harnessed by using the attributes contained in the Combo HTML tags. You can also set these events through JavaScript.

The available events include:

  • OnAfterInitialize() - Fires immediately following initialization.
  • OnShowEvent() and OnHideEvent() - Fire when the dropdown appears and disappears.
  • OnBeforeSearchEvent() and OnAfterSearchEvent() - Fire before and after dataset searching occurs.
  • OnBeforeSelectEvent() and OnSelectEvent() - Fire before and after a user selects a record.
  • OnEditKeyUpEvent() - Fires when a keypress is released (only keys that affect the text displayed).
  • OnFocusEvent() and OnBlurEvent() - Fires when the control receives and loses focus.
  • OnTabEvent() - Fires when the user tabs out of the control.

The Special Case

onAfterInitialize is a special case. This event is not accessed like the others. To harness this event, create a JavaScript function in your <head> tag like this:

function OnAfterIntializeEbaCombos()
{
   // Some code here
}

Nitobi Combo will automatically look for this function. If it exists, it will be executed immediately following initialization of the combo.

The HTML Attributes

You can set all of the other events using the HTML attributes. Different events belong to different objects. Here is a template for your use:

<ntb:Combo id="myCombo"
     OnBlurEvent="myFunction()"
     OnFocusEvent="myFunction()"
     OnHideEvent="myFunction()"
     OnShowEvent="myFunction()"
     OnBeforeSelectEvent="myFunction()"
     OnSelectEvent="myFunction()"
     OnTabEvent="myFunction()"
     Mode="classic" >
 <ntb:ComboTextBox
     Width="250px"
     DataFieldIndex=0
     OnEditKeyUpEvent="myFunction()">
     </ntb:ComboTextBox>
 <ntb:ComboList
     Width="360px"
     Height="205px"
     DatasourceUrl="get.asp"
     PageSize="12"
     OnBeforeSearchEvent="myFunction()"
     OnAfterSearchEvent="myFunction()">
 </ntb:ComboList>
</ntb:Combo>

Setting Events with JavaScript

Alternatively you can set events with JavaScript. You must do this after the nitobi.initCombo() call.

eg:

myCombo.SetOnShowEvent("myFunction()");
myCombo.SetOnHideEvent("myFunction()");
myCombo.SetOnBeforeSelectEvent("myFunction()");
myCombo.SetOnSelectEvent("myFunction()");
myCombo.GetList().SetOnBeforeSearchEvent("myFunction()");
myCombo.GetList().SetOnAfterSearchEvent("myFunction()");
myCombo.GetTextBox().SetOnEditKeyUpEvent("myFunction()");
myCombo.SetOnFocusEvent("myFunction()");
myCombo.SetOnBlurEvent("myFunction()");
myCombo.SetOnTabEvent("myFunction()");
page_revision: 3, last_edited: 1225227006|%e %b %Y, %H:%M %Z (%O ago)
Unless stated otherwise Content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License