List<loadondemand> treeData = GetTreeData();
IEnumerable<loadondemand> results;
if (dm.Where == null)
{
//return the first level nodes
results = treeData.Where(item => item.pid == null);
}
else
{
//return the nodes which has pid as we request
results = treeData.Where(s => s.pid == Convert.ToInt32(dm.Where[0].value));
}
return results;
} |
<EjsTreeView ID="tree">
<TreeViewFieldsSettings Query="new ej.data.Query()" Id="nodeId" Text="nodeText" HasChildren="hasChild" ParentID="pid" Expanded="expanded">
<EjsDataManager Url="/api/Default" Adaptor="Adaptors.UrlAdaptor" CrossDomain="true"></EjsDataManager>
</TreeViewFieldsSettings>
</EjsTreeView> |
<EjsTreeView ID="tree">
<TreeViewFieldsSettings Query="new ej.data.Query().addParams('ParentID','5')" Id="employeeID" Text="firstName" HasChildren="employeeID">
<EjsDataManager Url="/api/Default" Adaptor="Adaptors.UrlAdaptor" CrossDomain="true"></EjsDataManager>
<TreeViewFieldChild Id="orderID" Text="customerID" ParentID="employeeID" Expanded="expanded">
<EjsDataManager Url="api/Child" Adaptor="Adaptors.UrlAdaptor" CrossDomain="true"></EjsDataManager>
</TreeViewFieldChild>
</TreeViewFieldsSettings>
</EjsTreeView> |
// Extends the DataManager
public class CustomClass : DataManagerRequest
{
public CustomParams Params { get; set; }
}
// Definition for the additional parameter
public class CustomParams
{
public int ParentID { get; set; }
}
[HttpPost]
public object Post([FromBody]CustomClass dm)
{
BindDataSource();
var data = order.AsQueryable();
var count = order.Count;
var queryString = dm.Params.ParentID;
if (dm.Where == null)
{
int top = Convert.ToInt32(queryString);
results = data.Where(s => s.EmployeeID == top);
}
return results;
} |