我正在尝试使用 Ext Js 定义一个下拉组合框,它将显示我保存在数组中的“假期”。请纠正我可能出错的地方,因为 JSP 不会显示组合框下拉菜单。
...
<body>
<div class="left " style="color:#333333;padding-bottom:8px;padding-left:13px;width:99%;" id="Holiday">
<span class="formastrickmargin"><strong></strong></span>
</div>
<div id="Holiday" class="left " style="padding-bottom:6px;padding-left:15px;width:99%;">
</div>
</body>
<script type="text/javascript">
var availableTags = ["New years Day", "Martin Luther King Day", "Groundhog Day", "Valentine's Day", "Washington's Birthday",
"Easter", "Earth Day", "National Arbor Day", "Mother's Day", "Memorial Day", "Flag Day", "Father's Day",
"Independence Day", "Labor Day", "Columbus Day", "Halloween", "Veterans Day", "Thanksgiving Day"];
var combo1;
var defaultDDText = 'Enter the Site Id here, or select from dropdown.';
var Holidaystore = new Ext.data.ArrayStore({
root: 'availableTags',
autoLoad:true,
fields: ['availableTags'],
data: availableTags
});
Ext.onReady(function(){
Ext.QuickTips.init();
function initializeHoliday(){
combo1 = new Ext.form.ComboBox({
id:'Holiday',
typeAhead: true,
triggerAction: 'all',
emptyText: defaultDDText,
store:Holidaystore,
selectOnFocus:true,
width:408,
listWidth: '410',
mode: 'local',
minChars : '3',
renderTo:'Holiday',
displayField: 'availableTags',
}); }
initializeHoliday();
});
</script>
最佳答案
我将从移除 root 开始:或者
var availableTags = { data : ["New years Day", "Martin Luther King Day", "Groundhog Day", "Valentine's Day", "Washington's Birthday", "Easter", "Earth Day", "National Arbor Day", "Mother's Day", "Memorial Day", "Flag Day", "Father's Day", "Independence Day", "Labor Day", "Columbus Day", "Halloween", "Veterans Day", "Thanksgiving Day"] };
下一个根:data
关于javascript - Extjs 组合框帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4733225/