来自 威尼斯国际官方网站 2019-10-09 23:24 的文章
当前位置: 威尼斯国际官方网站 > 威尼斯国际官方网站 > 正文

威尼斯国际官方网站及质量测验

 

博客搬迁,给你带来的不便,敬请谅解!

$('.strTree li div input:checkbox').click(function () {//问题:如何实现选中车队,对应成员全部选中,并传对应所有成员的member_id,而不是传team_id

                team_id = document.getElementsByName($(this).attr('id1'));    //通过name   获取name='team_id'的子元素        ($(this).attr('id'))为被选中的车队名               
                team = document.getElementById($(this).attr('id')); //通过id获取   获取的是被勾选的车队或者车辆的id              
                if (team.checked) {
                    for (i = 0; i < team_id.length; i++) {
                        team_id[i].checked = true;
                    }
                } else {
                    for (i = 0; i < team_id.length; i++) {
                        team_id[i].checked = false;
                    }                  
                }

                //alert(team_id.length);
                var indexs = [];          
                var vehIds = [];         
                $(".strTree li div input:checkbox:checked").each(function (i) {  //由于复选框选中多个,所以循环输出
                    v = document.getElementsByName($(this).attr('id1'));
                    //alert("v的值" + v.length);
                    if (v.length == 0) {
                        //vehIds[i] = $(this).attr('id2') + "|" + $(this).attr('id3');                       
                        indexs[i] = $(this).attr('id2');
                        vehIds[i] = $(this).attr('id3');
                    } 
                    //vehIds[i] = $(this).attr('id');   //attr() 方法设置或返回被选元素的属性值            

                });              
                for (var i = 0; i < indexs.length; i++) {            //清除vehIds[]中的所有空字符串
                    if (indexs[i] == '' || indexs[i] == null || typeof (indexs[i]) == undefined) {
                        indexs.splice(i, 1);
                        i = i - 1;
                    }
                }
                for (var i = 0; i < vehIds.length; i++) {            //清除vehIds[]中的所有空字符串
                    if (vehIds[i] == '' || vehIds[i] == null || typeof (vehIds[i]) == undefined) {
                        vehIds.splice(i, 1);
                        i = i - 1;
                    }
                }                                        
                self.vehIds = vehIds;
                self.indexs = indexs;

                var path = 'TeamMap.aspx';
                window.parent.frames['target_right'].location = path;
                Loading(true);
            });

http://www.suanliutudousi.com/2017/11/15/js%e4%b8%ad%e5%87%a0%e7%a7%8d%e5%8a%a8%e6%80%81%e5%88%9b%e5%bb%ba%e5%85%83%e7%b4%a0%e5%b9%b6%e8%ae%be%e7%bd%ae%e6%96%87%e6%9c%ac%e5%86%85%e5%ae%b9%e7%9a%84%e6%af%94%e8%be%83%ef%bc%8c%e5%8f%8a%e6%80%a7/

 

 

车队对应的id为team_id,车辆对应的id为veh_id,在每个车队中,所有车辆对应同一个team_id

选中cqupt1,则对应所有成员car1,car2自动选中,地图上显示车队中的所有车辆位置信息

1、首先在TeamTree.aspx.cs文件中

http://blog.csdn.net/kissing7/article/details/8920566

对应代码如下:

把team_id从父节点函数中传递到子节点函数中,

 

http://www.codeweblog.com/jquery%e6%93%8d%e4%bd%9c%e5%a4%8d%e9%80%89%e6%a1%86-checkbox-%e7%9a%8412%e4%b8%aa%e5%b0%8f%e6%8a%80%e5%b7%a7%e6%80%bb%e7%bb%93/

 

 

 

 1 /// <summary>
 2         /// 创建子节点
 3         /// </summary>
 4         /// <param name="list">list</param>
 5         /// <returns></returns>
 6         public string GetTreeNode(IList list)
 7         {
 8             Info_Veh_Team info_veh_team = new Info_Veh_Team();
 9             StringBuilder sb_TreeNode = new StringBuilder();
10             List<Info_Veh_Team> itemNode = IListHelper.IListToList<Info_Veh_Team>(list);   
11   
12             int index1 = 0;
13             string strclass = "";
14             if (itemNode.Count > 0)
15             {
16                 sb_TreeNode.Append("<ul>");
17                 foreach (Info_Veh_Team entity in itemNode)
18                 {
19                     if (index1 == 0)
20                         strclass = "collapsableselected";
21                     else
22                         strclass = "";
23                     sb_TreeNode.Append("<li>");
24                     sb_TreeNode.Append("<div class='" + strclass + "'><input id='" + entity.team_id + "' type='checkbox' id1='" + index1 + "' />" + entity.team_name + "</div>");
25                     
26                     info_veh_team = info_veh_teamibll.GetEntity(entity.team_id);
27                     StringBuilder where = new StringBuilder();
28                     where.Append("and team_id='" + info_veh_team.team_id + "'");      
29                     IList nextlist = info_team_memberibll.GetListWhere(where, null);
30                     sb_TreeNode.Append(GetTreeNodeNext(nextlist, index1));
31                     sb_TreeNode.Append("</li>");
32                     index1++;
33                 }
34                 sb_TreeNode.Append("</ul>");
35             }
36             return sb_TreeNode.ToString();
37         }
38         /// <summary>
39         /// 创建子节点
40         /// </summary>
41         /// <param name="list">list</param>
42         /// <returns></returns>
43         public string GetTreeNodeNext(IList list, int index1)
44         {
45             StringBuilder sb_TreeNode = new StringBuilder();
46             List<Info_Team_Member> itemNode = IListHelper.IListToList<Info_Team_Member>(list);
47             int index = 0;
48             string strclass = "";
49             if (itemNode.Count > 0)
50             {
51                 sb_TreeNode.Append("<ul>");
52                 foreach (Info_Team_Member entity in itemNode)
53                 {
54                     if (index == 0)
55                         strclass = "collapsableselected";
56                     else
57                         strclass = "";
58                     sb_TreeNode.Append("<li>");
59                     sb_TreeNode.Append("<div class='" + strclass + "'><input id='" + entity.member_id + "' type='checkbox'  name='" + index1 + "' id2='" + index1 + "' id3='" + entity.veh_lpn + "'/>" + entity.veh_lpn + "</div>");
60                     sb_TreeNode.Append("</li>");
61                     index++;
62                 }
63                 sb_TreeNode.Append("</ul>");
64             }
65             return sb_TreeNode.ToString();
66         }

sb_TreeNode.Append("<div class='" + strclass + "'><input id='" + entity.team_id + "' type='checkbox' /><span>" + entity.team_name + "</span></div>");

威尼斯国际官方网站 1

本文由威尼斯国际官方网站发布于威尼斯国际官方网站,转载请注明出处:威尼斯国际官方网站及质量测验

关键词: