質問

I have a TestField (Single line of text) that I can return a value to while in NewForm.aspx. The problem being, the TextBox disappears and it only displays the returned text itself.

(function () {
   var ctx = {};
   ctx.Templates = {};
   ctx.Templates.Fields = {
       'TestField': { 'NewForm': renderTestField }
   }

   SPClientTemplates.TemplateManager.RegisterTemplateOverrides(ctx);
})();


function renderTestField(ctx)
{
   return 'TestText';

   //Will the below code work with a custom value in it??
   //return <input type="text" value="" maxlength="255" id="Dig_x0020_ID_b5482683-9113-41be-b2ea-8095919a2fd4_$TextField" title="Dig ID" class="ms-long ms-spellcheck-true">
}

I would like to return the text inside the original TextBox so the user can still edit it. What should my renderTextField function look like?

Should I return the original HTML which is being rendered? Do I need the long ID?

EDIT: I tried returning the Original <input> HTML from the JSLink, but it doesn't save to the List Item

役に立ちましたか?

解決

Try as below

function renderTestField(ctx) {
    ctx.CurrentFieldValue = "TestText";
    return SPFieldText_Edit(ctx);
}

You can set custom value as below also

function renderTestField(ctx) {
    return '<input type="text" maxlength="255" id="Dig_x0020_ID_b5482683-9113-41be-b2ea-8095919a2fd4_$TextField" title="Dig ID" class="ms-long ms-spellcheck-true" value="TestValue"/>';
}
ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top