gpt4 book ai didi

javascript - 来自本地数组的 ExtJs Combobox

转载 作者:太空狗 更新时间:2023-10-29 14:56:43 27 4
gpt4 key购买 nike

我正在尝试使用本地数组列表填充 Ext Js 组合框。在 Ext Js 示例中,组合是从不同的 states.js 文件填充的。

在我的示例中,数据应该来自局部变量。它不起作用。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Combo Boxes</title>
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../ext-all.js">
</head>

<body>
<script type="text/javascript">
var exampleData2 = [['1', 'hello'],['2', 'hi'],['3', 'bye']];
Ext.onReady(function(){
Ext.QuickTips.init();

// simple array store
var store = new Ext.data.ArrayStore({
fields: ['abbr', 'state'],
data : exampleData2
});
var combo = new Ext.form.ComboBox({
store: store,
displayField:'state',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'Select a state...',
selectOnFocus:true,
applyTo: 'local-states'
});
</script>

<div>
<input type="text" id="local-states" size="20"/>
</div>
<div id="local-states" style="margin-top:10px">

</body>
</html>

最佳答案

范围,范围,范围

Ext.onReady(function(){   Ext.QuickTips.init();  // simple array store   var exampleData2 = [['1', 'hello'],['2', 'hi'],['3', 'bye']];  var store = new Ext.data.ArrayStore({     fields: ['abbr', 'state'],     data : exampleData2      // or even better data : [['1', 'hello'],['2', 'hi'],['3', 'bye']]     // next to change: combo.getStore().loadData( new_table );  });  var combo = new Ext.form.ComboBox({     store: store,     displayField:'state',     typeAhead: true,     mode: 'local',     forceSelection: true,     triggerAction: 'all',     emptyText:'Select a state...',     selectOnFocus:true,     applyTo: 'local-states'   });});

得到更复杂的解决方案

Ext.ux.states = Ext.Extend ( Ex.form.ComboBox, { ....

关于javascript - 来自本地数组的 ExtJs Combobox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4884406/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com