亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Manuel de référence chinois jQuery EasyUI / jEasyUI樹(shù)形網(wǎng)格惰性加載節(jié)點(diǎn)

jEasyUI樹(shù)形網(wǎng)格惰性加載節(jié)點(diǎn)

有時(shí)我們已經(jīng)得到充分的分層樹(shù)形網(wǎng)格(TreeGrid)的數(shù)據(jù)。 我們還想讓樹(shù)形網(wǎng)格(TreeGrid)按層次惰性加載節(jié)點(diǎn)。 首先,只加載頂層節(jié)點(diǎn)。 然后點(diǎn)擊節(jié)點(diǎn)的展開(kāi)圖標(biāo)來(lái)加載它的子節(jié)點(diǎn)。 本教程展示如何創(chuàng)建帶有惰性加載特性的樹(shù)形網(wǎng)格(TreeGrid)。

116.png

創(chuàng)建樹(shù)形網(wǎng)格(TreeGrid)

	<table id="test" title="Folder Browser" class="easyui-treegrid" style="width:700px;height:300px"
			data-options="
				url: 'data/treegrid_data.json',
				method: 'get',
				rownumbers: true,
				idField: 'id',
				treeField: 'name',
				loadFilter: myLoadFilter
			">
		<thead>
			<tr>
				<th field="name" width="220">Name</th>
				<th field="size" width="100" align="right">Size</th>
				<th field="date" width="150">Modified Date</th>
			</tr>
		</thead>
	</table>

為了放置加載子節(jié)點(diǎn),我們需要為每個(gè)節(jié)點(diǎn)重命名 'children' 屬性。 正如下面的代碼所示,'children' 屬性重命名為 'children1'。 當(dāng)展開(kāi)一個(gè)節(jié)點(diǎn)時(shí),我們調(diào)用 'append' 方法來(lái)加載它的子節(jié)點(diǎn)數(shù)據(jù)。

'loadFilter' 代碼

	function myLoadFilter(data,parentId){
		function setData(){
			var todo = [];
			for(var i=0; i<data.length; i++){
				todo.push(data[i]);
			}
			while(todo.length){
				var node = todo.shift();
				if (node.children){
					node.state = 'closed';
					node.children1 = node.children;
					node.children = undefined;
					todo = todo.concat(node.children1);
				}
			}
		}
		
		setData(data);
		var tg = $(this);
		var opts = tg.treegrid('options');
		opts.onBeforeExpand = function(row){
			if (row.children1){
				tg.treegrid('append',{
					parent: row[opts.idField],
					data: row.children1
				});
				row.children1 = undefined;
				tg.treegrid('expand', row[opts.idField]);
			}
			return row.children1 == undefined;
		};
		return data;
	}

下載 jQuery EasyUI 實(shí)例

jeasyui-tree-treegrid5.zip