[CLOSED] there is no remove method in treestore?

  1. #1

    [CLOSED] there is no remove method in treestore?

    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>
    Click image for larger version. 

Name:	QQ截图20130921190333.jpg 
Views:	14 
Size:	44.2 KB 
ID:	6920
    Last edited by Daniil; Oct 04, 2013 at 6:43 AM. Reason: [CLOSED]
  2. #2
    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();
    }

Similar Threads

  1. [CLOSED] TreeStore issue with 2.2
    By paulc in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 19, 2013, 10:24 AM
  2. Replies: 10
    Last Post: May 31, 2013, 1:54 PM
  3. Replies: 3
    Last Post: Apr 10, 2013, 5:05 AM
  4. [CLOSED] TreePanel & TreeStore setRootNode() not working anymore?
    By cleve in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 15, 2013, 4:16 PM
  5. Add Remove
    By cbu in forum 1.x Help
    Replies: 3
    Last Post: Jan 10, 2012, 9:23 PM

Posting Permissions