使用JSLink为新上传的项目设置内容类型(EditForm.aspx) [英] Use JSLink to set Content Type for new uploaded Items (EditForm.aspx)

查看:39
本文介绍了使用JSLink为新上传的项目设置内容类型(EditForm.aspx)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在尝试使用JSLink为newform.aspx设置特定的内容类型。但是我没有成功。

i'm trying to set a specific content type with JSLink for the newform.aspx. But i am not successful with this.

我注册了JSLink文件并尝试使用客户端模板定义访问内容类型字段,但这没有成功。我的另一种方法是在后渲染操作中包含一个函数,并尝试更改为下拉列表值。这个
有效,但后来没有保存更改。你有什么提示吗?

I registered the JSLink file and tried to access the content type field with the Client template definition, but this was not successful. My other approach was to include a function in the post render action and try to change to drop down list value. This works, but the change was not saved later. Do you have any hint for me?

这是当前的代码,ddl.value = ...有效,但ddl.trigger ('更改')没有效果:

Here is the current code, the ddl.value=... works, but ddl.trigger('change') does not have an effect:


function (){

推荐答案

您可以查看我的以下测试代码。

 <script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script type="text/javascript">
        (function () {
            //retrieveFieldsOfListView('Dokumente','Meldewesen');
            // Create object that have the context information about the field that we want to change it's output render
            var setMeldewesenCategoryCtx = {};
            setMeldewesenCategoryCtx.Templates = {};
            setMeldewesenCategoryCtx.Templates.OnPostRender =changeCtDropDownValue;
            //setMeldewesenCategoryCtx.Templates.Item =itemTemplate;
            SPClientTemplates.TemplateManager.RegisterTemplateOverrides(setMeldewesenCategoryCtx);
        })();
        // this function change content type dropdown box value
        function changeCtDropDownValue(ctx) {
            SP.SOD.executeOrDelayUntilScriptLoaded(loadContext, 'sp.js');
            function loadContext() {
                var srcUrl = decodeURI(GetSource());
                var parentUrl =window.parent.location.href;
                console.log(ctx);
                console.log(parentUrl);
                //use contentypeid to avoid Infinite loop
                if (parentUrl.indexOf('0x0100AB1FFADFDA28FE4F9DA02DB68B3862C9') > 0) {
                    console.log('inner if')
                    var ddl =


('select [name * = ContentTypeChoice]')
var ddo =
('select[name*=ContentTypeChoice]') var ddo =


(ddl).find('option' ).filter(function(){
return
(ddl).find('option').filter(function () { return


这篇关于使用JSLink为新上传的项目设置内容类型(EditForm.aspx)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆