3

我在我的三个共享点站点上遇到了这个问题,我设法通过修改 CSS 代码来解决这个问题(参见http://social.msdn.microsoft.com/Forums/en-US/sharepoint2010general/thread/64796605-bcbb-4a87- 9d8d-9d609579577f/)在其中两个上。

我不知道为什么这不适用于具有相同更新、相同 CSS 和相同 html 代码的第三个...我尝试了几种解决方案,例如添加 indesign="true"(这不能使用,因为列表有超过 75 列)。cf http://www.codeproject.com/Articles/194254/Advanced-fixing-SharePoint-2010-large-lookup-dropd

我发现的唯一解决方案需要javascript,但我真的不想使用它......

如果有人提出另一种解决方案,我将不胜感激。

编辑:感谢moontear,我发现了一些非常棒的东西。我将脚本的开头替换为: $(document).ready(function () {

$('.ms-lookuptypeintextbox').each(function(){
    OverrideDropDownList($(this).attr('title'));
});

// Main Function
function OverrideDropDownList(columnName) {
...

通过这种方式,我只需要包含脚本而不关心哪些列有问题......

4

2 回答 2

2

这个脚本似乎很好地解决了这个问题......谢谢moontear的评论原始脚本来自:http ://sharepointegg.blogspot.de/2010/10/fixing-sharepoint-2010-lookup-drop- down.html

$(document).ready(function () {

$('.ms-lookuptypeintextbox').each(function(){
    OverrideDropDownList($(this).attr('title'));
});

// Main Function
function OverrideDropDownList(columnName) {

// Construct a drop down list object
var lookupDDL = new DropDownList(columnName);

// Do this only in complex mode...
if (lookupDDL.Type == "C") {

// Hide the text box and drop down arrow
lookupDDL.Obj.css('display', 'none');
lookupDDL.Obj.next("img").css('display', 'none');

// Construct the simple drop down field with change trigger
var tempDDLName = "tempDDLName_" + columnName;
if (lookupDDL.Obj.parent().find("select[ID='" + tempDDLName + "']").length == 0) {
lookupDDL.Obj.parent().append("<select name='" + tempDDLName + "' id='" + tempDDLName + "' title='" + tempDDLName + "'></select>");

lookupDDL.Obj.parent().find("select[ID='" + tempDDLName + "']").bind("change", function () {
updateOriginalField(columnName, tempDDLName);
});
}

// Get all the options
var splittedChoices = lookupDDL.Obj.attr('choices').split("|");

// get selected value
var hiddenVal = $('input[name=' + lookupDDL.Obj.attr("optHid") + ']').val();
if (hiddenVal == "0") {
hiddenVal = lookupDDL.Obj.attr("value")
}

// Replacing the drop down object with the simple drop down list
lookupDDL = new DropDownList(tempDDLName);

// Populate the drop down list
for (var i = 0; i < splittedChoices.length; i++) {
var optionVal = splittedChoices[i];
i++;
var optionId = splittedChoices[i];

var selected = (optionId == hiddenVal) ? " selected='selected'" : "";
lookupDDL.Obj.append("<option" + selected + " value='" + optionId + "'>" + optionVal + "</option>");
}
}
}

// method to update the original and hidden field.
function updateOriginalField(child, temp) {
var childSelect = new DropDownList(child);
var tempSelect = new DropDownList(temp);

// Set the text box
childSelect.Obj.attr("value", tempSelect.Obj.find("option:selected").val());

// Get Hidden ID
var hiddenId = childSelect.Obj.attr("optHid");

// Update the hidden variable
$('input[name=' + hiddenId + ']').val(tempSelect.Obj.find("option:selected").val());
}

// just to construct a drop down box object. Idea token from SPServces
function DropDownList(colName) {
// Simple - when they are less than 20 items
if ((this.Obj = $("select[Title='" + colName + "']")).html() != null) {
this.Type = "S";
// Compound - when they are more than 20 items
} else if ((this.Obj = $("input[Title='" + colName + "']")).html() != null) {
this.Type = "C";
// Multi-select: This will find the multi-select column control on English and most other languages sites where the Title looks like 'Column Name possible values'
} else if ((this.Obj = $("select[ID$='SelectCandidate'][Title^='" + colName + " ']")).html() != null) {
this.Type = "M";
// Multi-select: This will find the multi-select column control on a Russian site (and perhaps others) where the Title looks like '????????? ????????: Column Name'
} else if ((this.Obj = $("select[ID$='SelectCandidate'][Title$=': " + colName + "']")).html() != null) {
this.Type = "M";
} else
this.Type = null;
} // End of function dropdownCtl
});
于 2012-07-11T13:43:36.620 回答
1

上面解决方案中的代码很棒,但它有两个主要缺点:

1) 不能很好地与必需的字段验证器配合使用 2) 不能很好地配合通过 SPServices 的级联下拉菜单。

我已经在工作中解决了这两个问题,并将我的解决方案放在这里: http ://craigvsthemachine.blogspot.com/2013/04/fixing-complex-dropdown-bug-in.html

于 2013-04-27T20:27:19.497 回答