听棠.NET

用积极乐观的心态,面对压力
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

WebCombo的客户端对象模型

Posted on 2005-01-06 15:18  听棠.NET  阅读(3432)  评论(2编辑  收藏  举报

在NetAdvantage 中那些控件都有客户端对象模型,对于UltraWebGrid等都是很容易就找到的,对于WebCombo不太好找,现在贴出来,可供参考,如果要对WebCombo中下拉的Grid进行客户端控制的话,可以使用getGrid()方法后得到Grid对象,这个对象其实就是UltraWebGrid的对象,其客户端模型可以参考UltraWebGrid的模型了。
NetAdvantage WebCombo的客户端对象模型如下:
The Combo Object of UltraWebCombo can be obtained within the page using the igcmbo_getComboById utility function.

var combo =igcmbo_getComboById('UltraWebCombo1');

The combo can also be referenced directly through the definition that is automatically generated for it. If the name of the combo on the server is 'UltraWebCombo1' then a variable called oUltraWebCombo1 will be available from anywhere within the page. The 'o' prefix is a convention used to indicate that the variable is an object as opposed to an HTML element. When a variable represents an HTML element, an 'e' is prefixed in front of it.

This topic also contains the following sections:

Properties

CancelPostback

Gets or sets a Boolean value that indicates whether postback should be cancelled when the next event occurs. If a postback is set to occur due to some other client-side activity, setting this property to True will prevent the postback from occurring. This property can be changed on the client.
var combo = igcmbo_getComboById('UltraWebCombo1');
combo.CancelPostBack = true;

DataTextField

Identifies the column key value used as the source of display text in the top portion of the WebCombo. This property corresponds to the property of the same name on the server. This property is read-only and should not be changed on the client.

DataValueField

Identifies the column key value used as the source of data values posted back to the server for WebCombo. This property corresponds to the property of the same name on the server. This property is read-only and should not be changed on the client.

Editable

Returns a Boolean value that indicates whether or not the WebCombo element is editable in the top portion of the element. If true, the user can enter their own values in the combo, if false they user is restricted to selecting values already present in the dropdown. This property corresponds to the property of the same name on the server. This property is read-only and should not be changed on the client.
var combo = igcmbo_getComboById('UltraWebCombo1');
var canBeEdited = combo.Editable;

Element

Returns the HTML element object corresponding to the WebCombo on the page. This property is read-only and should not be changed.
var element = igcmbo_getComboById('WebCombo1').Element; element.style.color = "red";

Events

See below for Events.

ExpandEffects

This property returns an object that contains the values set for the expand effects that will be supplied when WebCombo is dropped down. For more detail, see the ExpandEffects object topic. The ExpandEffects object contains the same properties as the server-side version. This object corresponds to the property of the same name on the server.
var expfx = igcmbo_getComboById('WebCombo1').ExpandEffects; expfx.Duration = 100;
expfx.Opacity = 70;

Id

Returns the HTML id property of the top-level WebCombo element on the page. This property is read-only and should not be changed.
var id = oUltraWebCombo1.Id;

NeedPostback

Gets or sets a Boolean value that indicates whether a postback should be initiated after the following event occurs. Set this property to True to force a manual postback to occur after the next event. This property can be changed on the client.
oWebCombo.NeedPostBack = true;

Methods

getDisplayValue()

Returns the current value of the top portion of the Webcombo element.

    Parameters:
    None.

var value = oCombo.getDisplayValue();

getDropDown()

Returns a boolean value that indicates whether or not the WebCombo dropdown is currently displayed.

    Parameters:
    None.

if(oCombo.getDropDown())
    return;
else
    oCombo.setDropDown(true);

getGrid()

Returns a reference to the oGrid object that manages the dropdown area of the WebCombo element. This object supports the entire object and programming model of the WebGrid element on the client.

    Parameters:
    None.
var oGrid = oCombo.getGrid();
// Turn off sorting in the dropdown
oGrid.AllowSort = 2;

getSelectedIndex()

Returns the index offset of the currently selected row of the dropdown grid.

    Parameters:
    None.

var index = oCombo.getSelectedIndex();

getVisible()

Returns a boolean value that indicates whether or not the WebCombo element is visible on the page.

    Parameters:
    None.

var visible = oCombo.getVisible();
if(!visible)
    oCombo.setVisible(true);

setDisplayValue(newValue, bFireEvent)

Sets the value and the text in the top portion of the WebCombo element to the passed in newValue parameter. The second parameter, bFireEvent, is a boolean value that indicates whether BeforeSelectChange and AfterSelectChange events should be fired on the client.

    Parameters:
    newValue - A string value that will be assigned to the element.
    bFireEvent - A Boolean value that specifies whether the BeforeSelectChange and AfterSelectChange client-side events should be fired. If true, the events will occur.

oCombo.setDisplayValue("John Doe", true);

setDropDown(bDrop)

This method controls the dropdown state of WebCombo. Passing true as a parameter causes the dropdown to display if it is not already displayed. Passing false causes the dropdown to dissappear if it is visible.

    Parameters:
    bDrop - A Boolean value that specifies the dropped-down state of the element.

oCombo.setDropDown(true);

setVisible(bVisible)

Sets the visiblity of the WebCombo according to the passed-in Boolean value. If true, the WebCombo element is displayed at its current position. If false, the WebCombo element is hidden on the page.

    Parameters:
    bVisible - A Boolean value that specifies the visibility of the WebCombo element.

oCombo.setVisible(false);

setWidth(width)

Sets the width of the WebCombo element in pixels.

    Parameters:
    width - An integer value that specifies the width of the element.

oCombo.setWidth(150);

Events

The Events object contains over 25 members that are used to specify JavaScript function handlers that are called in response to a variety of events occurring on the client. The Event member is only populated with a valid JavaScript function if the function name is set from the Events object of the DisplayLayout object on the server. 

All events are called with at least one parameter: The ID of the WebCombo on which the event occurred. In the case of the EditKeyDown and EditKeyUp events, additional parameters are added which specify thecurrent or new value for the edit portion of the combo, and the keycode of the keystroke that caused the event.

The members of the Events object are:

  • AfterCloseUp(id)
  • AfterDropDown(id)
  • AfterSelectChange(id)
  • BeforeCloseUp(id)
  • BeforeDropDown(id)
  • BeforeSelectChange(id)
  • EditKeyDown(id, currentValue, keyCode)
  • EditKeyUp(id, newValue, keyCode)
  • InitializeCombo(id)