PDA

View Full Version : [CLOSED] there is no remove method in treestore?



hdsoso
Sep 21, 2013, 11:05 AM
a treepanel, in it a TreeSelectionModel and a treestore,
how to remove the selected row using tree store?


<ext:TreePanel
ID="TreePanel1"
runat="server"
Title="栏目管理"
ColumnLines="True">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button runat="server" Text="删除" Icon="Delete">
<Listeners>
<Click Handler="var selection = #{TreeSelectionModel1}.getSelection();
if (selection) {
#{TreePanel1}.store.remove(selection);// here error, no remove method
};" />
</Listeners>
</ext:Button>
<ext:Button runat="server" Text="确定" Icon="Disk">
<DirectEvents>
<Click OnEvent="BatchUpdate">
<ExtraParams>
<ext:Parameter Name="data" Value="App.TreePanel1.store.getChangedData()" Mode="Raw" Encode="true" />
</ExtraParams>
<EventMask ShowMask="True"></EventMask>
</Click>
</DirectEvents>
</ext:Button>
<ext:Button ID="bt_fresh" runat="server" Text="刷新" Icon="PageRefresh">
<Listeners>
<Click Handler="window.location='column.aspx';"></Click>
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Root>
<ext:Node NodeID="0" Text="根节点">
<CustomAttributes>
<ext:ConfigItem Name="id" Value="0"/>
<ext:ConfigItem Name="colname" Value="根栏目"/>
</CustomAttributes>
</ext:Node>
</Root>
<Listeners>
<BeforeLoad Fn="nodeLoad" />
</Listeners>
<Store>
<ext:TreeStore runat="server" ID="s_column">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="id"></ext:ModelField>
<ext:ModelField Name="colname"></ext:ModelField>
<ext:ModelField Name="pid"></ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:TreeStore>
</Store>
<ColumnModel>
<Columns>
<ext:Column runat="server" DataIndex="id" Text="编号"></ext:Column>
<ext:TreeColumn runat="server" DataIndex="colname" Text="栏目" Flex="1">
<Editor>
<ext:TextField runat="server"></ext:TextField>
</Editor>
</ext:TreeColumn>
<ext:Column runat="server" DataIndex="pid" Text="父id">
<Editor>
<ext:NumberField runat="server"></ext:NumberField>
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
<Plugins>
<ext:CellEditing runat="server"></ext:CellEditing>
</Plugins>
<SelectionModel>
<ext:TreeSelectionModel ID="TreeSelectionModel1" runat="server" Mode="Multi" />
</SelectionModel>
</ext:TreePanel>


6920

Daniil
Sep 23, 2013, 6:20 AM
Hi @hdsoso,

Indeed, there is no remove method in TreeStore. IMO, it is lack in the ExtJS API. I see related discussion on the Sencha forums, but for some reason they didn't add the method.

Please use the following script.

var tree = App.TreePanel1,
selection = tree.getSelectionModel().getSelection(),
i, len;

for (i = 0, len = selection.length; i < len; i++) {
selection[i].remove();
}