天天看点

easyui中combotree与combobox并用动态加载数据

最开始是做flex的,jsp这些东西懂,但是对ui框架这些东西就比较生疏了,最近在做微信的项目,公司后台框架是easyui的,做起来就比较费事了,今天遇到一个问题,就是用combotree把商品类型树状形式展示,对应的商品下拉框中会对应类型的改变而改变。在网上找了一些资料,没什么现成的,自己试了下,还是可以实现的。可能网上有,比较笨,没有找到。自己总结一下,方便以后看,也方便别人。

jsp页面中两个下拉框

<span style="font-family: Arial, Helvetica, sans-serif;"><tr></span>
           
<td align="right">商品类型:</td>
				<td align="left">
					<input style="width:200px;" name="typeParent" id="typeParent" class="easyui-combotree" data-options="url:'goodstype/list.html?parentId=0',
					onBeforeExpand:function(node){$('#typeParent').combotree('tree').tree('options').url = 'goodstype/list.html?parentId='+node.id;},
					onLoadSuccess:function(){$('#typeParent').combotree('tree').tree('expandAll');},panelHeight:'250'"/>
				</td>
			</tr>
			<tr>
				<td align="right">所属商品:</td>
				<td align="left">
					<select name="goodsId" id="goodsId" editable="false" style="width:200px;" required="true" class="easyui-combobox" 
						data-options="
							url:'goods/selGoodsByType.html',
							valueField:'gid',
							textField:'goodsName',
							panelHeight:'auto'
							
					"></select>
				</td>
			</tr>
           

js代码

$('#typeParent').combotree({onSelect:function(node) {
		$('#goodsId').combobox({ 
	    	url:'goods/selGoodsByType.html?typeId='+node.id,
			valueField:'gid',
			textField:'goodsName',
			panelHeight:'auto'
		});
  		}
	})
           

有什么问题可以一起讨论