我正在尝试从 SharePoint 中的文档库加载文档,并且希望能够从我的应用程序中按文件类型(Word 文档、Excel 工作表等)过滤它们。我已经弄清楚如何使用 获取文件类型的图标mapToIcon,但我似乎无法在任何地方找到如何获取文件类型。
是否有任何函数或 API 调用可以获取文件的文件类型?我不想根据文件扩展名对每种类型进行硬编码,但我可能需要这样做。
这是我的一些代码供参考
// data returned from an ajax call to get all documents
var results = data.d.results;
for(var i = 0; i < results.length; i++){
// get the name of the document
var name = results[i].Name;
// retrieve the icon for the file type through an ajax call
var icon;
$.ajax({
url: siteUrl + "/_api/web/maptoicon(filename='" + name + "',progid='',size=0)"
/*headers*/,
success: function(data){
// get the icon
icon = data.d.MapToIcon;
}, …Run Code Online (Sandbox Code Playgroud) 我的目标是找出我的 SharePoint 列表中的列类型,以便使用正确类型的字段填充表单。经过一番挖掘,我在有关访问特定属性的文档中找到了这篇文章。
我也发现这个问题问了我同样的问题,但从未得到解决。在我的代码中,我试过
..url.../_api/web/lists/GetByTitle('...list name...')/columnName
Run Code Online (Sandbox Code Playgroud)
但是,当它找不到资源时,我会收到 404 错误。
访问 SharePoint 列表中的列的正确语法是什么?