在检查/取消检查树列表中的节点后如何中断

发布于 2024-12-09 03:35:11 字数 2215 浏览 0 评论 0原文

我有一个小问题。 我应该实现一个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 种情况:

  • #1。 if 1 <= 组 <= 100 ->强制服务,仅允许
  • 第 2 组中的一项。 if 101 <= 组 <= 1000 ->强制服务,至少允许团体中的一名,但允许更多
  • #3。如果组>= 1001 ->可选服务,选中/取消选中组中的所有内容。

结果: #3 我已经做得很简单,但是我如何实现#1。

I have a little problem.
i should implement a logic for a treeList which consist from a single parent and more children grouped into more groups by ID's.

I have an action which treats all nodes:

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);

I have 3 cases:

  • #1. if 1 <= group <= 100 -> Mandatory Service, allow only ONE from group
  • #2. if 101 <= group <= 1000 -> Mandatory Service, allow minimum ONE from group, but allow and MORE
  • #3. if group >= 1001 -> optional Service, Check/ Uncheck ALL from group.

Result:
The #3 I've done easy, but how can i implement #1.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

仄言 2024-12-16 03:35:11

对于#1,我找到了一个实现:

//for ' 1 <= group <= 100' ->强制服务,团体中仅限一项

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;
                                        }
                                    }
                                }
                            }`

for #1 i found an implementation:

//for ' 1 <= group <= 100' -> Mandatory Service, only ONE from group

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;
                                        }
                                    }
                                }
                            }`
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文