使用:
YADCF过滤器有效。但是在用户选择过滤条目后,页面会卡在顶部。滚动条不起作用。你根本无法移动页面。如果用户选择过滤器类型然后刷新页面,则滚动将使用仍在框中的过滤器类型。按清除,滚动仍然有效。选择一个新的过滤条目并滚动中断。
DataTables自由文本搜索框不会发生这种情况。它仅在操作YADCF过滤器时发生。因此必须修复YADCF或Select2代码。
或者,this might explain what's happening,但我无法访问母版页。想知道是否this could be a work around但我不知道如何实施sp.clientruntimecontext.executequeryasync电话。
任何想法或想法将不胜感激。非常感谢。
<script type="text/javascript" charset="utf8" src="https:/mysite/SiteAssets/jquery.dataTables.min.js"></script>
<script type="text/javascript" charset="utf8" src="https:/mysite/SiteAssets/jquery.dataTables.yadcf.js"></script>
<script type="text/javascript" charset="utf8" src="https:/mysite/SiteAssets/moment-with-locales.min.js"></script>
<script type="text/javascript" charset="utf8" src="https:/mysite/SiteAssets/select2.full.min.js"></script>
<script type="text/javascript" charset="utf8" src="https:/mysite/SiteAssets/chosen.jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="https:/mysite/SiteAssets/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https:/mysite/SiteAssets/jquery.dataTables.yadcf.css">
<link rel="stylesheet" type="text/css" href="https:/mysite/SiteAssets/select2.css">
<link rel="stylesheet" type="text/css" href="https:/mysite/SiteAssets/chosen.min.css">
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead><th>Name</th><th>No.</th><th>Date</th><th>Memo</th><th>Classification</th><th>Class2</th><th>Class3</th> </thead>
</table>
<script type="text/javascript">
_spBodyOnLoadFunctionNames.push(ExecuteOrDelayUntilScriptLoaded(AMDB, 'sp.ui.pub.ribbon.js'));
function AMDB(){
var call = $.ajax({
url: "https:/mysite/_vti_bin/listdata.svc/AM?$select=Title,Number,Date,Name,Classification/Classification,Class2/Class2,Class3/Class3&$expand=Classification,Class2,Class3",
async: "true",
type: "GET",
dataType: "json",
headers: {Accept: "application/json;odata=verbose"}
});//close ajax call
call.done(function (data,textStatus, jqXHR){
myData = data.d.results;
var dtTable = $('#example').DataTable({
responsive: true,
data: myData,
columns:[
{data:"Title"},
{data:"Number"},
{data:"Date","render": function (data, type, full, meta) {return moment.utc(data, "x").format('l');}},
{data:"Name","render":function(data, type, full, meta){return'<a href="https:/mysite/AM/'+data+'">Click here</a>';}},
{data: "Classification.results[, ].Classification"},
{data: "Class2.results[, ].Class2"},
{data: "Class3.results[, ].Class3"}
],
stateSave: true
}); //close DataTable
答案 0 :(得分:0)
此问题是由具有无效$ -character的SharePoint元素ID引起的,该元素随后用于jQuery事件命名空间。添加eventhandler有效,但删除它失败,因为找不到它的事件处理程序。 $ -character需要从事件命名空间中转义或删除。
我没有合适的解决方案,但在SharePoint 2013中有效的解决方法:
var initialSelect = $("#" + fieldSchema.Name + "_" + fieldSchema.Id + "_\\$LookupField");
initialSelect.select2();
// workaround for issue causing invalid-namespace in event-handlers - select2 uses use the container-element.id as event-namespace but sharepoint has $ in element-id that's not valid
initialSelect.on("select2:close", function (e) {
$("div#s4-workspace.ms-core-overlay").off('scroll.select2.select2-' + e.target.id.replace("$", "\\\$"));
});