jQuery EasyUI 表單 – 創(chuàng)建樹形下拉框(ComboTree)

2022-06-08 16:36 更新

jQuery EasyUI 表單 - 創(chuàng)建樹形下拉框

本節(jié)介紹如何創(chuàng)建jQuery EasyUI的樹形下拉框(ComboTree)。

樹形下拉框是一個(gè)帶有下列樹形結(jié)構(gòu)(Tree)的下拉框(ComboBox)。它可以作為一個(gè)表單字段進(jìn)行使用,可以提交給遠(yuǎn)程服務(wù)器。

在下述的示例中,我們將要?jiǎng)?chuàng)建一個(gè)帶有name、address、city字段的注冊(cè)表單。city字段是一個(gè)樹形下拉框字段,在里面用戶可以下拉樹面板(tree panel),并選擇一個(gè)特定的城市。

創(chuàng)建表單(Form)

	<div id="dlg" class="easyui-dialog" style="width:500px;height:250px;padding:10px 30px;" title="Register" buttons="#dlg-buttons">
		<h2>Account Information</h2>
		<form id="ff" method="post">
			<table>
				<tr>
					<td>Name:</td>
					<td><input type="text" name="name" style="width:350px;"/></td>
				</tr>
				<tr>
					<td>Address:</td>
					<td><input type="text" name="address" style="width:350px;"/></td>
				</tr>
				<tr>
					<td>City:</td>
					<td><select class="easyui-combotree" url="data/city_data.json" name="city" style="width:156px;"/></td>
				</tr>
			</table>
		</form>
	</div>
	<div id="dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="savereg()">Submit</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">Cancel</a>
	</div>

從上面的代碼可以看到,我們?yōu)橐粋€(gè)名為'city'的樹形下拉框字段設(shè)置了一個(gè)url屬性,這個(gè)字段可以從遠(yuǎn)程服務(wù)器檢索樹形結(jié)構(gòu)(Tree)數(shù)據(jù)。請(qǐng)注意,這個(gè)字段有一個(gè)樣式名字叫'easyui-combotree',所以我們不需要寫任何的js代碼,樹形下拉框(ComboTree)字段將自動(dòng)渲染。

下載 jQuery EasyUI 實(shí)例

jeasyui-form-form2.zip

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)