Skip to main content

ASPxClientMenuItem.GetItemCount Method

Returns the number of the current menu item’s immediate child items.

Declaration

GetItemCount(): number

Returns

Type Description
number

The number of the immediate subitems of the current menu item.

Remarks

A menu control’s client-side functionality allows the immediate child items of a particular menu item to be accessed programmatically. The GetItemCount method is used to determine the number of the current menu item’s submenu items which are maintained by the item’s MenuItem.Items collection. This method can be used together with the ASPxClientMenuItem.GetItem method when iterating through the item’s list of the immediate subitems to determine its upper bound.

Example

...
<dxm:ASPxMenu ID="ASPxMenu1" runat="server" BorderBetweenItemAndSubMenu="HideAll"
            OnItemClick="ASPxMenu1_ItemClick" SelectParentItem="True" ShowPopOutImages="True">
            <Items>
                <dxm:MenuItem Text="Root 1">
                    <Items>
                        <dxm:MenuItem Text="Sub Item">
                            <Items>
                                <dxm:MenuItem Text="Item 1-1">
                                </dxm:MenuItem>
                                <dxm:MenuItem Text="Item 1-2">
                                </dxm:MenuItem>
                            </Items>
                        </dxm:MenuItem>
                        <dxm:MenuItem Text="Item 1-3">
                        </dxm:MenuItem>
                    </Items>
                </dxm:MenuItem>
                <dxm:MenuItem Text="Root 2">
                    <Items>
                        <dxm:MenuItem Text="Item 2-1">
                        </dxm:MenuItem>
                        <dxm:MenuItem Text="Item 2-2">
                        </dxm:MenuItem>
                        <dxm:MenuItem Text="Item 2-3">
                        </dxm:MenuItem>
                    </Items>
                </dxm:MenuItem>
            </Items>
            <ClientSideEvents ItemClick="function(s, e) {
    e.processOnServer = e.item.GetItemCount() == 0; // Prevent generating a postback for parent menu items
           }" />
</dxm:ASPxMenu>
... 
See Also