data menu data source
- type:
array | function
- default:
no default
- usage:
the SelectMenu data source have 3 types: regular menu type,advanced menu type(single group and multiple group)
Regular menu data format
//regular menu data item format /** * content [string] : Menu item display content, support html format(Set the content to "sm_divider" to generate a divider bar) * header [boolean] : whether menu header item * url [string] : visit page url * callback [function] : The callback function when menu item selected * disabled [boolean] : whether disabled current menu item */ var menuData = [ {content:'News Site',header: true},//menu header item {content:'163 NetEase',url : 'http://www.163.com'},//Link type menu item {content:'sm_divider'},//the menu divider //Use HTML format to display menu item content, and set menu item disabled {content:' Facebook',url : 'https://www.facebook.com',disabled : true}, //Click the menu item to perform the callback {content:'Click this menu item to trigger your callback',callback : function(){ bDialog.alert('you can do anything in callback!'); }} ];
Advanced menu data format (single group)
//Advanced menu data example (non-group) //The data format different with regular, the menu item data format can be custom completely //you can used 'keyField'、'showField' and 'searchField' parameters to bind var selectMenuData = [ {id:1 ,name:'Chicago Bulls',desc:'芝加哥公牛',abbr:'CHI'}, {id:2 ,name:'Cleveland Cavaliers',desc:'克里夫兰骑士',abbr:'CLE'}, {id:3 ,name:'Detroit Pistons',desc:'底特律活塞',abbr:'DET'}, {id:4 ,name:'Indiana Pacers',desc:'印第安纳步行者',abbr:'IND'}, {id:5 ,name:'Milwaukee Bucks',desc:'密尔沃基雄鹿',abbr:'MIL'} ];
Advanced menu data format (multiple group)
//multiple group type data source format //Requirement The data structure must be set in the following format //but 'list' node data format, like the non-grouped data format var selectMenuGroupData = [{ title : 'East', list :[ {id:1 ,name:'Chicago Bulls',desc:'芝加哥公牛',abbr:'CHI'}, {id:2 ,name:'Cleveland Cavaliers',desc:'克里夫兰骑士',abbr:'CLE'} ] },{ title : 'West', list : [ {id:16,name:'Denver Nuggets',desc:'丹佛掘金',abbr:'DEN'}, {id:17,name:'Minnesota Timberwolves',desc:'明尼苏达森林狼',abbr:'MIN'} ]} ];
when data set to function, the data source can be dynamic acquisition
showField menu item display content data field, available on advanced menu mode
- type:
string
- default:
'name'
- usage:
set the data field to show menu item display content
keyField menu key field in data, available on advanced menu mode
- type:
string
- default:
'id'
- usage:
set to get the key value from data field
lang menu using language
- type:
string
- default:
'cn'
- usage:
available option
code language cn Chinese en English de German es Spanish pt-br Brazilian Portuguese ja Japanese
searchField search results data field
- type:
string
- default:
option.showField
- usage:
set search results in data field, if non-set then using '
showField
' appoint data field
multiple menu item multiple select
- type:
boolean
- default:
false
- usage:
setting SelectMenu selection mode, default is single selection mode
search whether show quick search bar
- type:
boolean
- default:
true
- usage:
setting menu is show quick search bar or not (autocomplete)
only work on advanced menu mode
title whether show title bar
- type:
string | boolean
- default:
'SelectMenu'
- usage:
setting title bar display content, if set to
false
, will close the title bar
regular set menu mode to regular menu mode
- type:
boolean
- default:
false
- usage:
set menu mode to regular mode, in this mode, menu item just can link jump or execute callback function
rightClick mouse right button click to call menu
- type:
boolean
- default:
false
- usage:
Set menu open mode in the specified area, click the right mouse button to call menu, the default open mode for the button or link and other objects click after the trigger
arrow whether show menu arrow, when menu show type is pop up type (not embedded mode, not mouse right click mode)
- type:
boolean
- default:
false
- usage:
setting menu show arrow, and point to caller
not working on embedded menu mode
embed: true
and mouse right click moderightClick: true
position menu align the caller direction
- type:
string
- default:
'left'
- usage:
Set menu align the caller direction
'left'
(default)'center'
'right'
embed menu embedded to page, non pop up
- type:
boolean
- default:
false
- usage:
whether embedded menu in to page
initSelected selected menu item when menu init complete
- type:
any
- default:
undefined
- usage:
Set selected menu item when menu init complete, which matches the
option.keyField
field, and if it matches, it is automatically selected and highlightedthe setting only work on advanced menu mode (
regular: false
)
listSize menu result list display size
- type:
number
- default:
10
- usage:
The height of the menu is based on how many items are displayed
selectToCloseList select the menu item and close the menu
- type:
boolean
- default:
false
- usage:
set whether select the menu item and close menu, only work on advanced menu mode and 'multiple' set to true
formatItem custom menu item display template
- type:
function
- default:
undefined
- usage:
param1:data,menu item data (single item) return:string (support html type)
andOr the way to query data ('AND' or 'OR')
- type:
string
- default:
'AND'
- usage:
andOr : 'OR'
setting that using multiple keywords into the query, the menu's processing logic
the multiple keywords use space to Separate
orderBy data sort type
- type:
array
- default:
used 'showField' The specified columns are sorted in ascending order
- usage:
orderBy : ['id desc','name']
If only columns are specified and no sorting is specified, the default Ascending order is used
the multiple keywords use space to Separate
eSelect Respond to the event processing when menu item selected
- type:
function
- default:
undefined
- usage:
parameter
data:the menu items data (json) for selected menu item
example
eSelect : function(data){ $('xxx').val(data.name + data.sex); }
eTabSwitch Respond to menu group switch in multiple group data mode
- type:
function
- default:
none
- usage:
parameters:
index: group index,start from 0
tab: group data,not included 'list' data
eTabSwitch : function(index, tab){ do something... }
eHidden Respond to menu hide
- type:
function
- default:
无
- usage:
parameters:data - selected items data
eHidden : function(data){ $('xxx').val(data.name + data.sex); }
$.fn.selectMenuHide close menu
- type:
function
- default:
none
- usage:
$('#someone').selectMenuHide();
$.fn.selectMenuClear clean selected menu items(in advanced menu mode)
- type:
function
- default:
none
- usage:
$('#someone').selectMenuClear();
$.fn.selectMenuValues get selected items data(in advance menu mode)
- type:
function
- default:
none
- usage:
var data = $('#someone').selectMenuValues();//[Object,Object,...]