I am using igTree with LoadOnDemand is set to true.
I have a WCF REST Service which giving me data to populate in igTree.
Please find the sample code..
$.ajax(
{
type: "GET",
url: "AssessmentProcWCFService.svc/GetAllEntities",
contentType: "application/json; charset=utf-8",
dataType: 'json',
data: '{}',
cache: false,
success: OnGetAllEntitiesSuccess,
error: OnGetAllEntitiesFailure
});
==================================================
function OnGetAllEntitiesSuccess(categoryList) {
$("#APTreeView").igTree({
animationDuration: 0,
dataSourceType: 'json',
dataSource: categoryList.d,
initialExpandDepth: false,
loadOnDemand: true,
dataSourceUrl: "AssessmentProcWCFService.svc/GetAllCategories?EntityID=primaryKey:id",
bindings: {
textKey: 'text',
valueKey: 'id',
primaryKey: 'id',
expanded: 'expanded',
childDataProperty: 'children'
}
=========================================================
Questions:-
1. How could I send the selected node ID to the Service when any node of the tree is expanding?
The way I am sending in the above example it is not working when I am retrieving it in the service “public List<APEntityTree> GetAllCategories()” like
“string entityID = HttpContext.Current.Request.QueryString["EntityID"];”
I am getting entity id as null.
2. How the tree get rendered when any node get expanded if LoadOnDemand is true?
Please help me on this I have spend lot of time in it.
Hi,
I ahve already done that as below, but still the tree is not getting expanded.
Any thoughts on this why it is not getting expanded.
var targetNode = categoryList.d.CreatedNode; var node = $('APTreeView').igTree("nodesByValue", targetNode.id); node = $('#APTreeView').igTree('nodeFromElement', node); $('APTreeView').igTree('select', node); $('APTreeView').igTree('expandToNode', node);
Thanks
Team Symantec
Hi again,
If the node ID is the node value then you can use the nodesByValue method to find it, call select with it and expandToNode. Otherwise use the findNodesByText and find it by text and then expandToNode and select.
Let me know if this works!
I have added a new node to the data source of tree and rebind and also i can see the newly created node when i exapnd the tree
Code Sample:-.
$('#APTreeView').igTree('option', 'dataSource', categoryList.d.ListNode);
$(
'#APTreeView').igTree('dataBind');
Now i have the newly created node id and text with me i want the tree to be select that newly created node and expand till the newly created node path immediately after data bind, how can i achieve this.
Team Symantec.
Hi Anil,
Subscribe to the rendered event and create a flag for yourself to indicate whether this the first time rendered is being fired. Then inside the rendered event select the first node.
It should look like this:
var initialRender = true;
$(document).delegate('#APTreeView', 'igtreerendered', function (event, ui) {
if (initialRender) {
// Below will retrieve first node regardless of whether you have primary keys or not.
var node = $('#APTreeView').find('li[data-role=node]:first');
$('#APTreeView').igTree('select', node);
initialRender = false;
Thank you for using the Infragistics forums!
In the tree how could i select the first node of the tree by default, when the tree render first time?
Anil