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.
I forget to mention that i am trying to build a tree as follows.
===
Hi,
Thanks for your quick help,now i could able to get the data list when i am expanding any parent node but i could not able to see the child node inside it, is my binding is correct. i am just pasting the code sample of my two service methods.
[OperationContract] [WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)] public List<APEntityTree> GetAllEntities() { try { List<APEntityTree> listAPEntityTree = new List<APEntityTree>(); using (new WebImpersonationWrapper()) { WCFServerConnection serverConnection = new WCFServerConnection(Environment.MachineName);
IThirdPartyControlsProvider provider = serverConnection.BackEndThirdPartyCtrlProvider; List<AssociateResultEntityMasterUIObject> lstEntitiy = provider.GetAllEntities(); foreach (AssociateResultEntityMasterUIObject entity in lstEntitiy) { listAPEntityTree.Add(new APEntityTree() { id = entity.EntityID.ToString(), text = entity.DisplayName, expanded = false, data = new Data(), children = new List<APEntityTree>() }); } return listAPEntityTree; } } catch (Exception ex) { return new List<APEntityTree>(); } }
[OperationContract] [WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest)] public List<APEntityTree> GetAllCategories() { try { List<APEntityTree> listAPEntityTree = new List<APEntityTree>(); using (new WebImpersonationWrapper()) { WCFServerConnection serverConnection = new WCFServerConnection(Environment.MachineName);
Guid EntityID = new Guid(HttpContext.Current.Request.QueryString["EntityID"]); IThirdPartyControlsProvider provider = serverConnection.BackEndThirdPartyCtrlProvider; List<AssociateResultEntityMasterUIObject> lstEntitiy = provider.GetAllEntities(); AssociateResultEntityMasterUIObject entitiy = (from ent in lstEntitiy where ent.EntityID.Equals(EntityID) select ent).FirstOrDefault(); List<CategoryUIObject> lstCategoryUIObject = provider.GetAllCategories(entitiy); foreach (CategoryUIObject entity in lstCategoryUIObject) { listAPEntityTree.Add(new APEntityTree() { id = entity.EntityID.ToString(), text = entity.DisplayName, expanded = false, data = new Data(), children = new List<APEntityTree>() }); } return listAPEntityTree; } } catch (Exception ex) { return new List<APEntityTree>(); } }
Hi again,
You basically invoke the setOption method of the widget the following way:
$('#APTreeView').igTree('option', 'dataSourceUrl', 'http://new.request');
Thank you for using the Infragistics forums!
how do i set the "dataSourceUrl" inside the
$(document).delegate(
"#APTreeView", "igtreenodepopulating", function (evt, ui) {
Please let me know the child node will get rendered automatically after expand?
Hi there,
You are able to do this but it is not supported out of the box. What you would need to do further is to subscribe to the nodePopulating event and change the dataSourceUrl at runtime to reflect the EntityID that you're requesting. The node populating event exposes for you the node currently being populated so you can extract its primary key from the event arguments.
Let me know if this helps!