PDA

View Full Version : [CLOSED] Keep TreePanelīs selection after local sort



RCN
Jun 20, 2012, 2:25 PM
Hi folks, when a node is selected and then, a sort is performed, the selection is cleared.

Any idea to overcome this issue?



<ext:TreePanel ID="TreePanel2" SelType="Checkbox" runat="server" Title="Tree" Height="700"
Width="400" Margins="10" RootVisible="false" Border="false">
<Store>
<ext:TreeStore ID="TreeStore1" runat="server">
<Proxy>
<ext:AjaxProxy Url="/Example/LoadFakeChildren">
<ActionMethods Read="POST" />
<Reader>
<ext:JsonReader Root="data" />
</Reader>
</ext:AjaxProxy>
</Proxy>
</ext:TreeStore>
</Store>
<Root>
<ext:Node NodeID="0" Text="Root" />
</Root>
<Fields>
<ext:ModelField Name="Task" />
</Fields>
<ColumnModel>
<Columns>
<ext:TreeColumn ID="TreeColumn1" runat="server" Text="Task" Flex="2" Sortable="true"
DataIndex="Task" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel ID="CheckboxSelectionModel1" runat="server"
Mode="Multi" />
</SelectionModel>
</ext:TreePanel>




public StoreResult LoadFakeChildren()
{
NodeCollection nodes = new NodeCollection(false);

for (int index = 1; index < 6; index++)
{
Node no = new Node();
no.NodeID = index.ToString() + DateTime.Now.Second;
no.CustomAttributes.Add(new ConfigItem { Name = "Task", Value = no.NodeID, Mode = ParameterMode.Value });
nodes.Add(no);
}

return new StoreResult { Data = nodes.ToJson() };
}

Daniil
Jun 20, 2012, 8:05 PM
Hi,

I am not 100% sure the CheckboxSelectionModel and RowSelectionModel can be used with TreePanel. But why not? At least, I can't see any restriction in the ExtJS docs.

And it works if set up

PruneRemoved="false"
for the CheckboxSelectionModel.

See also
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.selection.Model-property-pruneRemoved

One doubt - it's marked as "private". I am not 100% sure there won't be any backside effects.

If you will face any troubles further, please report us.

RCN
Jun 23, 2012, 7:05 PM
it works like a charm. please mark it as resolved.