清除YADCF Select2 /自定义筛选器选项后,SharePoint页面粘贴到顶部/不会向下滚动

时间:2016-05-24 22:30:44

标签: sharepoint sharepoint-2010 datatables sharepoint-2013 yadcf

使用:

  • SharePoint 2010
  • jQuery 1.7.2(来自主站点,我无法访问)
  • DataTables 1.10.12
  • YADCF 0.8.9
    • select_type:select2
    • 过滤器类型:multi_select_custom_func
  • Select2 4.0.1
  • 选择1.5.1

YADCF过滤器有效。但是在用户选择过滤条目后,页面会卡在顶部。滚动条不起作用。你根本无法移动页面。如果用户选择过滤器类型然后刷新页面,则滚动将使用仍在框中的过滤器类型。按清除,滚动仍然有效。选择一个新的过滤条目并滚动中断。

DataTables自由文本搜索框不会发生这种情况。它仅在操作YADCF过滤器时发生。因此必须修复YADCF或Select2代码。

或者,this might explain what's happening,但我无法访问母版页。想知道是否this could be a work around但我不知道如何实施电话。

任何想法或想法将不胜感激。非常感谢。

<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

1 个答案:

答案 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("$", "\\\$"));
});