简体   繁体   English

SharePoint 2013中的自定义字段

[英]Custom Field in SharePoint 2013

I have been entrusted with migrating the existing custom plugin from SharePoint 2010 to 2013. SharePoint 2013 solution should create a custom column for which the data should be fetched from our product (application) using webservice. 我已被委托将现有的自定义插件从SharePoint 2010迁移到2013.SharePoint 2013解决方案应创建一个自定义列,应使用webservice从我们的产品(应用程序)中获取数据。 With 2010, the js file location and the function has been called from fldtypes_xxxx.xml file using the renderpattern. 在2010年,使用renderpattern从fldtypes_xxxx.xml文件调用了js文件位置和函数。 But with 2013, since the UI has changed, I'm not able to link the JS file. 但是在2013年,由于UI已经改变,我无法链接JS文件。 Hence I had to use the JSLink property. 因此我不得不使用JSLink属性。 Referred to the below msdn article and tried the same. 提到下面的msdn文章并试过同样的。

http://msdn.microsoft.com/en-us/library/jj220061%28v=office.15%29.aspx http://msdn.microsoft.com/en-us/library/jj220061%28v=office.15%29.aspx

Now I would like to make a webservice call from the JS file. 现在我想从JS文件中进行webservice调用。 I need to get the document's information like the listid, itemID and send it to our custom webservice which handles the request which inturn should send a webservice call to our external application and get the data for the appropriate document in sharepoint library. 我需要获取文档的信息,如listid,itemID,并将其发送到我们的自定义Web服务,该Web服务处理请求,该请求应该向我们的外部应用程序发送webservice调用并获取sharepoint库中相应文档的数据。

Please guide me on this. 请指导我这个。

How to add a call from the below function. 如何从以下功能添加呼叫。

(function () {
    var favoriteColorContext = {};

    favoriteColorContext.Templates = {};
    favoriteColorContext.Templates.Fields = {
        "FavoriteColorField": {
            "View": favoriteColorViewTemplate
        }
    };

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

function favoriteColorViewTemplate(ctx) {
    var color = ctx.CurrentItem[ctx.CurrentFieldSchema.Name];
    return "<span style='background-color : " + color +
        "' >&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;" + color;
}

You code above is for rendering field in the view. 您上面的代码用于在视图中渲染字段。 In this case, you can get these properties in favoriteColorViewTemplate function: 在这种情况下,您可以在favoriteColorViewTemplate函数中获取这些属性:

  • List ID: ctx.listName or from global variable _spPageContextInfo.pageListId 列表ID: ctx.listName或来自全局变量_spPageContextInfo.pageListId
  • Item ID: ctx.CurrentItem.ID 项目ID: ctx.CurrentItem.ID

If you will use functions in display or edit forms, these properties are a little bit different: 如果您将在显示或编辑表单中使用函数,这些属性有点不同:

  • List ID: ctx.FormContext.listAttributes.Id or _spPageContextInfo.pageListId 列表ID: ctx.FormContext.listAttributes.Id_spPageContextInfo.pageListId
  • Item ID: renderCtx.FormContext.itemAttributes.Id 项目ID: renderCtx.FormContext.itemAttributes.Id

Probably, the easiest way to call you custom web service is to use JQuery $.ajax(...) call. 也许,调用自定义Web服务的最简单方法是使用JQuery $.ajax(...)调用。 Check some samples here: 在这里检查一些样品:

  1. http://api.jquery.com/jquery.ajax/ http://api.jquery.com/jquery.ajax/
  2. http://www.w3schools.com/jquery/ajax_ajax.asp http://www.w3schools.com/jquery/ajax_ajax.asp

If you want to make reference to JQuery, you can do it also using JSLink, using | 如果你想引用JQuery,你也可以使用JSLink,使用| symbol like this: 像这样的符号:

{path to JQuery}|{path to your JS file}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM