本文介绍了检索具有2个以上查找字段以及图像字段的列表值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个列表'NewsList',列有标题,ShortDescription,图像,程序,分区和标记。 这里,程序,分区和标记是查找字段具有相同的列表名称。当我尝试检索值时,Title和ShortDescription会很好。但在Image,Programs,Division和Tag中,它显示[object Object]。我是SharePoint和NAPA的初学者。请帮助。 以下是我正在使用的代码片段。 function getitems(){ var hostUrl = decodeURIComponent(getQueryStringParameter( SPHostUrl)); var context1 = new SP.ClientContext.get_current(); hostcontext = new SP.AppContextSite(context1,hostUrl); web = hostcontext.get_web(); var selectedList = 新闻列表; var selectedListTitle = web.get_lists()。getByTitle(selectedList); var camlQuery = new SP.CamlQuery(); camlQuery.set_viewXml( < View>< ViewFields> + < FieldRef Name ='Title'/> + < FieldRef Name ='ShortDescription'/> + < FieldRef Name ='Image'/> + < FieldRef Name ='Programs'/> + < FieldRef Name ='Division'/> + < FieldRef Name ='Tag'/> + < / ViewFields>< /视图>')); listItemCollection = selectedListTitle.getItems(camlQuery); context.load(listItemCollection, Include(Title,ShortDescription,Image,Programs,Division,Tag) ); context.executeQueryAsync(onGetItemsSuccess,onGetItemsFail); } function onGetItemsSuccess(sender,args){ var listItemEnumerator = listItemCollection.getEnumerator(); var strTbl = ' ; strTbl = strTbl + ' < table>< tr>< td> Title< / td> < TD> SHORTDESCRIPTION< / TD>< TD>图像< / TD>< TD>程序< / TD>< TD>科< / TD>< TD>标记和LT; / TD>< / TR> ; while (listItemEnumerator.moveNext()){ var oListItem = listItemEnumerator.get_current(); strTbl = strTbl + ' < tr>< td>' + oListItem.get_item(' Title')+ ' < / td>< td>' + oListItem.get_item(' ShortDescription')+ ' < / td>' + ' < td>' + oListItem.get_item(' 图像')+ ' < / TD> + '< td> ' + oListItem.get_item('程序' )+' < / td > < td> ' + oListItem.get_item(' Division ' )+' < / td > ' + '< td> ' + oListItem.get_item('标记' )+' < / td > < / tr > ' ; } strTbl = strTbl +' < / table > ' ; $(' #dvNews ' )。html(strTbl); } 亲切帮助。解决方案 (' #dvNews ' )。html(strTbl); } 亲切帮助。 I have a list 'NewsList' with columns Title, ShortDescription,Image ,Programs,Division and Tag.Here, Programs,Division and Tag are lookup fields with same list name. When I try to retrieve the values, Title and ShortDescription are coming fine. But in Image, Programs,Division and Tag, its displaying [object Object]. I am a beginner to SharePoint and NAPA. Kindly help.Below is the snippet of the codes I am using.function getitems() { var hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl")); var context1 = new SP.ClientContext.get_current(); hostcontext = new SP.AppContextSite(context1, hostUrl); web = hostcontext.get_web(); var selectedList = "NewsList"; var selectedListTitle = web.get_lists().getByTitle(selectedList); var camlQuery = new SP.CamlQuery(); camlQuery.set_viewXml("<View><ViewFields>" + "<FieldRef Name='Title' />" + "<FieldRef Name='ShortDescription' />" + "<FieldRef Name='Image' />" + "<FieldRef Name='Programs' />" + "<FieldRef Name='Division' />" + "<FieldRef Name='Tag' />" + "</ViewFields></View>')"); listItemCollection = selectedListTitle.getItems(camlQuery); context.load(listItemCollection, "Include(Title, ShortDescription, Image, Programs, Division, Tag)"); context.executeQueryAsync(onGetItemsSuccess, onGetItemsFail);}function onGetItemsSuccess(sender, args) { var listItemEnumerator = listItemCollection.getEnumerator(); var strTbl = ''; strTbl = strTbl + '<table><tr><td>Title</td><td>ShortDescription</td><td>Image</td><td>Programs</td><td>Division</td><td>Tag</td></tr>';while (listItemEnumerator.moveNext()) { var oListItem = listItemEnumerator.get_current(); strTbl = strTbl + '<tr><td>' + oListItem.get_item('Title') + '</td><td>' + oListItem.get_item('ShortDescription') + '</td>' + '<td>' + oListItem.get_item('Image') + '</td> + '<td>' + oListItem.get_item('Programs') + '</td><td>' + oListItem.get_item('Division') + '</td>' + '<td>' + oListItem.get_item('Tag') + '</td></tr>';}strTbl = strTbl + '</table>'; $('#dvNews').html(strTbl); }Kindly Help. 解决方案 ('#dvNews').html(strTbl); }Kindly Help. 这篇关于检索具有2个以上查找字段以及图像字段的列表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-03 06:33