码迷,mamicode.com
首页 > 其他好文 > 详细

comboTagsTree的下拉框控件 选中

时间:2019-05-15 16:33:00      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:==   get   同步   搜索   map   reg   style   value   child   

//编辑的时候 点击默认下拉框中的值选中  每次选中一个将原本的替换掉 只能选中一个分组
if (groupId != "") {
if(updateGroup.length!=undefined&&updateGroup.length!=""&&updateGroup.length!=null){
for (var j = 0; j < updateGroup.length; j++) {

if (groupId == updateGroup[j].id) {
updateGroup[j].checked = true
parmss.push(updateGroup[j]);
break;
}
}
}else {
if (groupId == updateGroup.id) {
updateGroup.checked = true
parmss.push(updateGroup);
}
}
}
Schema.groupIds(updateGroup);
//有值的默认选中
if(parmss!=null&&parmss!==""){
$("#groupId").importTags(parmss);
}



//调用
groupIds:function (updateGroup) {
$("#groupId").removeAttr(‘data-tagstree-init‘);
$("#groupId").next().remove();
$("#groupId").comboTagsTree({
autocomplete_url: function (req, res) {
// 实现方式2:同步本地数据搜索实现,
var keyword = req.term,
data = updateGroup,
reg = new RegExp(keyword),
result = data.filter(function (item) {
return item.name && item.name.match(reg)
});
res($.map(result, function (item) {
return {
value: item.name,//选中后,填充到input框显示的值
id: item.id//选中后,填充到id里面的值
}
}));
},
onAddTag: function (tag) {
var tags = $("#groupId_tagstree .tag");
if(tags.length>1){
$("#groupId_tagstree .tag").eq(0).remove();
}

},
onRemoveTag: function (tag) {
var tags = $("#groupId").getTagsTreeTags();
if(tags!=null && tags.length>1){
for(var i in tags){
$(‘#groupId‘).removeTag(escape(tags[i].id));
}
}
},
onChange: function (obj, tags) {
if (tags && tags.length > 0) {
for (i in tags) {
$("span[title=" + tags[i].id + "]").attr("title", tags[i].name);//获取title名为aaa的值
$("#" + tags[i].id).html(tags[i].name); // 等同于 $("#text6").val(); ,只不过一个是数组,一个是字符串
}
}
},
tree: {
show: true,
selectOnlyLeaf:false,
selectChildren: ‘click‘, //选择节点方式 click:选择点击的节点, children: 选择子节点, all: 点击的节点及子节点
checkFilter: function (treeNode) { //选择树节点的过滤回调
return !!treeNode.id
},
nodeData: updateGroup
}

});
}

comboTagsTree的下拉框控件 选中

标签:==   get   同步   搜索   map   reg   style   value   child   

原文地址:https://www.cnblogs.com/320321ABab/p/10869668.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!