将逗号分隔的值显示到新行中 [英] Display comma separated values into new rows
本文介绍了将逗号分隔的值显示到新行中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下午好!
我有一个SharePoint,其中的列表列包含用逗号分隔的值.
I have a SharePoint with a list column containing values separated by commas.
如何使它们作为新项目显示在单独的行中?
How can I get them to display in separate rows as new items?
当前:A,B,C,D,E
Current: A, B, C, D, E
标题
Empl ID
新员工
1,2,3,4
我正在寻找的东西:
标题
Empl ID
新员工
1
新员工
2
新员工
3
新员工
4
访问权限和SPD可以成为解决方案的一部分.
Access and SPD can be part of the solution.
屏幕截图:
感谢您的帮助.
推荐答案
在下面的代码中修改列表名称,并将其添加到脚本编辑器Web部件中.
Modify the list name in the code below and add it to a script editor web part.
<table id="myTable" border="1" cellspacing="0" cellpadding="0" >
<tr>
<th style="padding-right:20px">Title</th>
<th style="padding-right:20px">Empl ID</th>
</tr>
<tbody id="tbody">
</tbody>
</table>
<script src="//code.jquery.com/jquery-1.12.4.js" type="text/javascript"></script>
<script type="text/javascript">
(function(){ GetAllListItems("CL7"); }); 函数GetAllListItems(listName){ var requestUri = _spPageContextInfo.webAbsoluteUrl +"/_ api/web/lists/getbytitle('" + listName +')/items"; //执行AJAX请求
(function () { GetAllListItems("CL7"); }); function GetAllListItems(listName){ var requestUri = _spPageContextInfo.webAbsoluteUrl+"/_api/web/lists/getbytitle('"+listName+"')/items"; //execute AJAX request
.ajax({ 网址:requestUri, 类型:"GET", 标头:{"ACCEPT":"application/json; odata = verbose"; }, 成功:功能(数据){ for(var i = 0; i< data.d.results.length; i ++){ var item = data.d.results [i]; var emplID = item.Empl_x0020_ID.split(','); for(var j = 0; j< emplID.length; j ++){
.ajax({ url: requestUri, type: "GET", headers: { "ACCEPT": "application/json;odata=verbose" }, success: function (data) { for(var i=0;i<data.d.results.length;i++){ var item=data.d.results[i]; var emplID=item.Empl_x0020_ID.split(','); for(var j=0;j<emplID.length;j++){
这篇关于将逗号分隔的值显示到新行中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文