-
[CLOSED] TreeGrid update
Hello,
I would want to do the following but it doesn't work as expected.
When I click a button a Ajax.request is sent to the server which returns a response in Json format. The response is in fact the content of my treegrid and I want to refresh the treeGrid with this response. I get the response correctly but unfortunately the treeGrid doesn't refresh.
As follow is the diffrent code I use:
The request is made with this ajax request
Code:
Ext.Ajax.request({
url: '<%= Url.Action("action", "controller") %>',
method: 'POST',
params: { data: data },
success: function(p1, p2) {
var nodes = eval(p1.responseText);
if(nodes.length > 0){
treeGrid.initChildren(nodes);
}
}
});
Here is the code of the action
Code:
[AcceptVerbs(HttpVerbs.Post)]
publicActionResult action(string data)
{
List<Dictionary<string, object>> dict = newList<Dictionary<string,object>>();
dict.Add(newDictionary<string, object>() { { "dateApproval", "tester" }, { "leaf", true } });
returnthis.Json(dict);
}
The TreeGrid is defined as follow
Code:
<ext:TreeGridID="treeGrid"runat="server"Title="titre"
AutoScroll="true"Height="200">
<Columns>
<ext:TreeGridColumnDataIndex="dateApproval"Width="200"/>
</Columns>
</ext:TreeGrid>
What is going wrong in my code and what should be done the have the code behave as wished?
Romuald.
-
Hi,
In the action you have to use TreeNodeCollction and call ToJson method for serialization
For example see the code of the http handler in the following example
https://examples1.ext.net/#/TreePane...Using_Handler/