前台代码:
<ext:DropDownField ID="ddfOrgNameId" runat="server" FieldLabel="XXX" LabelWidth="40"
Height="30" TriggerIcon="SimpleArrowDown" Editable="false" Mode="ValueText" Width="352">
<Triggers>
<ext:FieldTrigger Icon="Clear" Tag="clear" HideTrigger="false" />--这就是清除显示的那个×
</Triggers>
<Listeners>
<TriggerClick Handler="clearFilter(item);" />--清除的方法
</Listeners>
<Component>
<ext:TreePanel ID="OptionOrgTree" runat="server" AutoScroll="true" ContainerScroll="true"
RootVisible="false" UseArrows="true" Animate="true" Height="280">
<Store>
<ext:TreeStore ID="OptionOrgStore" runat="server">
<Proxy>
<ext:AjaxProxy Url="/Report/OrgProfit/GetOrgList">
</ext:AjaxProxy>
</Proxy>
<Parameters>--参数
<ext:StoreParameter Name="Id" Value="getSelectNodeIds(App.OptionOrgTree)" Mode="Raw" />
<ext:StoreParameter Name="IsShowCheckBox" Value="true" Mode="Raw" />
<ext:StoreParameter Name="isShowLowest" Value="false" Mode="Raw" />
<ext:StoreParameter Name="OrgSort" Value="0" Mode="Value" />
</Parameters>
<Listeners>--一些事件
<BeforeLoad Handler="SelectedCurrentNodes(App.OptionOrgTree, operation)" />
<Load Handler="SetDefaultNodes(App.OptionOrgTree,node)" />
</Listeners>
</ext:TreeStore>
</Store>
<Listeners>
<CheckChange Fn="dbchangeFrom">
</CheckChange>
<Load Handler="treeLoad(item,node,records,successful,options)" />
</Listeners>
<View>
<ext:TreeView ID="TreeView1" runat="server" LoadMask="true" LoadingText="loading...">
</ext:TreeView>
</View>
<SelectionModel>
<ext:TreeSelectionModel ID="TreeSelectionModel3" runat="server" Mode="Single">
</ext:TreeSelectionModel>
</SelectionModel>
</ext:TreePanel>
</Component>
</ext:DropDownField>
//清除数据
var clearFilter = function (item) {
App.ddfOrgNameId.reset();
var nodeList = getAllNodes();
for (var i = 0; i < nodeList.length; i++) {
var item = nodeList[i];
item.set("checked", false);
}
}
//获得下级的节点
function getAllNodes() {
var nodeList = new Array();
var root = App.OptionOrgTree.getRootNode();
getChild(nodeList, root);
return nodeList;
}
//获得子节点
function getChild(nodeList, node) {
for (i in node.childNodes) {
var cnode = node.childNodes[i];
nodeList.push(cnode);
getChild(nodeList, cnode);
}
}