リストビューで「グループ化」が有効になっている場合、リスト項目のクライアント側のレンダリングが適用される方法

sharepoint.stackexchange https://sharepoint.stackexchange.com//questions/78869

  •  10-12-2019
  •  | 
  •  

質問

ユーザーフレンドリー名列を隠すために、ドキュメントライブラリのタイトル列をファイルへのリンクとしてレンダリングするJavaScriptファイルを作成するためのいくつかの指示に従った。

(function () {
    var overrideCtx = {};
    overrideCtx.Templates = {};
    overrideCtx.Templates.Fields = {
        'LinkedToTitle': { 'View': '<a class="ms-listlink ms-draggable" href="<#= ctx.CurrentItem.FileRef #>" > <#= ctx.CurrentItem.Title #></a>' }
    };
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
})();
.

ビューでグループ化を設定するまで、すべてがうまく機能します。グループを展開すると、列は単に空白のままにされます(ただし、ページを更新してリンクを取り戻すことができます)。

JSLinkを適用しても、XMLフィールド定義に、Webパーツの編集、またはビューのASPXファイルの編集に関係なく、同じ結果が得られます。

サーバ側のレンダリング作業を使用して、ページの上部にあるビューセレクタリンクを失います。

リンクが表示され、ビューセレクタを保持する方法はありますか?好ましくは、CSRおよびXSLではなく、

役に立ちましたか?

解決 2

Discovered that this is actually a subset of the problem with CSR not being rendered due to the Minimal Download Strategy. Turning off the feature or using RegisterModuleInit as described here will solve the problem.

他のヒント

I have just managed to do something similar to what you were working on. Here is a link to my question where I have posted the working (so far) script.

Do not apply CSR Override in QuickEdit Mode

I thought it might still be relevant to you as it works in both MDS and non-MDS modes.

Disclaimer What I have found that works for MDS so far (note that I am using on-premises and have the ability to upload to layouts) ... Also, apologies if I have not correctly stated or understood any of the points below. Javascript and MDS is still in the black magic category for me ;-)

  1. Use a self executing wrapper function such as -

    function $global*filenameWithoutExtension*() { ... your code } $global*filenameWithoutExtension*();

  2. Upload your file to _layouts making sure that there are no extra '.'s in the name. For a library like jQuery, I actually rename the file and add the wrapper function around the existing minified jQuery.

  3. When registering the script (scriptlink etc) use the plain script name (which SharePoint then looks for in _layouts).
  4. If using a jslink, DO NOT use the ~layouts tag as when it renders the script reference in the page, it omits the leading /. (Use something like clienttemplates.js|kgjslinktitlefordocview.js instead).
  5. By default, any script reference on the page that has an entry function prefixed with $global seems to be automatically flagged by RegisterModuleInit for exclusion from MDS. Otherwise as noted you need to register it yourself. The registration and the script reference in the actual page need to match paths. This is I think why ~layouts token not rendering the leading slash prevents these scripts from registering properly.
ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top