开发者

How break after checking / unchecking a node in a treelist

开发者 https://www.devze.com 2023-04-11 17:36 出处:网络
I have a little problem. i should implement a logic for a treeList which consist from a single parent and more childrengrouped into more groups by ID\'s.

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 开发者_如何学Goall 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.


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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号