PDA

View Full Version : [CLOSED] Raw property is null when adding a node



RCN
Jun 22, 2012, 9:39 PM
Hi folks, when i append a node the raw property is null.

to reproduce the problem, please do the following steps:

Click Append Child button
Select the appended node


Any idea to overcome this issue?



<script type="text/javascript">
var appendChild = function () {
Ext.net.DirectMethod.request({
url: "/Example/GetNewChild",
cleanRequest: true,
success: function (result) {
App.TreePanel2.getRootNode().appendChild([result], false, true);
}
});
}

var selectNode = function (item,record,index) {
if (record.raw == null) {
alert("Raw is null");
}
else {
alert("Raw is not null");
}
}
</script>




<ext:Button Text="Append Child" runat="server">
<Listeners>
<Click Handler="appendChild();" />
</Listeners>
</ext:Button>
<ext:TreePanel ID="TreePanel2" SelType="Checkbox" runat="server" Title="Tree" Height="700"
Width="400" Margins="10" RootVisible="false" Border="false">
<Listeners>
<Select Fn="selectNode" />
</Listeners>
<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>
</ext:TreePanel>




public AjaxResult GetNewChild()
{
AjaxResult result = new AjaxResult();

result.Result = new { Task = "raphael" };

return result;
}

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() };
}

Vladimir
Jun 22, 2012, 9:58 PM
CustomAttribute name must be presented in Model as ModelField (or inside Fields collection of TreePanel)
See
http://examples2.ext.net/#/TreePanel/Advanced/TreeGrid/

RCN
Jun 22, 2012, 10:10 PM
take a look on line 27

Vladimir
Jun 22, 2012, 10:23 PM
If you use a store then fields must be defined inside Model of that Store
We will add exception if Fields of TreePanel is used with Store

RCN
Jun 22, 2012, 10:50 PM
Thank you, please mark it as closed