我有点问题。 我应该为treeList实现一个逻辑,该逻辑由单个父节点组成,而更多的子节点由ID组成更多的组。
我有一个处理所有节点的动作:
long callerGroup = -1L;
if (callerNode != null)
{
var service = this.tlServices.GetDataRecordByNode(callerNode) as __ServiceInfo;
if (service != null)
{
callerGroup = service.Group;
}
}
Action<TreeListNodes> action = null;
action = (nodes) =>
{
if (nodes != null && nodes.Count > 0)
{
foreach (TreeListNode node in nodes)
{
if (node.Level == 0 && !node.Checked)
{
node.Checked = true;
break;
}
else
{
var service = this.tlServices.GetDataRecordByNode(node) as __ServiceInfo;
if (service != null)
{
var group = service.Group;
//for ' 1 <= group <= 100' -> Mandatory Service, only ONE from group
if (callerGroup >= 1 && callerGroup <= 100)
{
if (group >= 1 && group <= 100)
{
//node.Checked = true; - not done
}
}
//for ' 101 <= group <= 1000 ' -> Mandatory Service, minimum ONE from group, but allow and MORE
if (callerGroup >= 101 && callerGroup <= 1000)
{
}
//for ' group >= 1001 ' -> optional Service, ALL from group
if (callerGroup >= 1001 && group >= 1001)
{
node.Checked = !node.Checked; // --> DONE.
}
}
}
action(node.Nodes);
}
}
};
action(this.tlServices.Nodes);
我有3个案例:
结果: #3我做得很轻松,但我怎样才能实现#1。
答案 0 :(得分:0)
对于#1我找到了一个实现:
//代表'1&lt; = group&lt; = 100' - &gt;强制服务,只有一组来自
if (callerGroup >= 1 && callerGroup <= 100)
{
if (group >= 1 && group <= 100)
{
foreach (TreeListNode nd in nodes)
{
var svc = this.tlServices.GetDataRecordByNode(nd) as __ServiceInfo;
long gr = svc.Group;
if (gr == callerGroup && nd.Checked == true)
{
nd.Checked = false;
}
}
}
}`