質問

I'm trying to use client side rendering to fix the width of the columns for my sharepoint (2013) list.

I've picked up the code from https://kogzee.wordpress.com/2013/10/21/sharepoint-2013-using-client-side-rendering-jslink-to-change-column-widths-in-lists/

But it does not work.

So my code is

(function () {
 // Initialize the variable that stores the objects.
 var overrideCtx = {};
 overrideCtx.Templates = {};
 overrideCtx.OnPostRender = postRenderHandler;

 // Register the template overrides.
 SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);
 })();

// The postRenderHandler attends the OnPostRender event
 function postRenderHandler(ctx) {
$("div[name='Comments1']").css("width","80px");
$("div[name='Comments2']").css("width","80px");
}

The console debugger comes up with the error

SCRIPT1006: Expected ')'

Within the debugger, the code looks like -

 $(�div[name=�Comments1�]�).css(�width�, �80px�);
 $(�div[name=�Comments2�]�).css(�width�, �80px�);

this doesn't seem quite right! I've tried replacing the single quotes with double quotes and the other way around.

Suggestions on what I might have done wrong?

Thanks

役に立ちましたか?

解決

I've added in the JQuery command...

(function () { (window.jQuery || document.write('<script   src="oursites.../jquery-1.11.3.js"><;\/script>'));

Also the detail lines had to be like this:

$('div[name="Comments"]').css('width',"270px"); $('div[name="Program_x0020_Details"]').css('width',"270px"); 

and it works fine. Thanks everyone for your help!

ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top