• Display number of replies in disscussion board


    how to display number of replies in disscussion board

    I have a require about display the replies' number in disscussion board, finish it via jQuery.

    First, get the number of the replies of each items via client object model,

    then store the number into array.

    at last, show it in page via jQuery .

    here is the code.

    <script type="text/javascript">
    		
          $(document).ready(function(){
               
                         ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "SP.js");
    	});
    	
    function retrieveListItems() {
    
        var clientContext = new SP.ClientContext.get_current();  
        var oList = clientContext.get_web().get_lists().getByTitle('Dis1');
            
        var camlQuery = new SP.CamlQuery();
        camlQuery.set_viewXml('<View><Query>' +
        	'<OrderBy>'+
      		'<FieldRef Name="DiscussionLastUpdated" Ascending="False"></FieldRef>'+
    		'</OrderBy>'+
                                       '</Query><RowLimit>20</RowLimit></View>');
    
        this.collListItem = oList.getItems(camlQuery, 'Include(ItemChildCount)');
            
        clientContext.load(collListItem);
            
        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));        
            
    }
    
    function onQuerySucceeded(sender, args) {
    	
    	var arr = new Array();
    	var listItemInfo = '';
        var listItemEnumerator = collListItem.getEnumerator();
        arr.length = 0;
        while (listItemEnumerator.moveNext()) {
            var oListItem = listItemEnumerator.get_current();
            listItemInfo = oListItem.get_item('ItemChildCount');
            arr.push(listItemInfo);
        }
        
        $('#forum0-PostList>li').each(function(index){
    	 		$(this).find('div.ms-comm-postMainContainer').css({"float":"left", "width":"90%"});
    	 		var arrValue = arr.shift()
    	 		$(this).find('div.ms-comm-postMainContainer').after("<div class = 'div_showNumber' style = 'float:left;font-size:20px;10%;background-color:gray;color:white;30px;height:30px;text-align:center;'>" + arrValue + "</div>");
    	});
    	
    
     }
    
    function onQueryFailed(sender, args) {
    
        alert('Request failed. ' + args.get_message() + '
    ' + args.get_stackTrace());
    }
    	
    	
    </script>
      


     

  • 相关阅读:
    静态类和静态类成员(C# 编程指南)
    sealed(C# 参考)
    C#高级知识点概要(2)
    线程并发和异步
    CXF+Spring+Hibernate实现RESTful webservice服务端实例
    Spring Boot 实现RESTful webservice服务端实例
    Spring Boot 实现RESTful webservice服务端示例
    Spring Boot REST API 自动化测试
    Biee插入图形时报错-超过了已配置的已允许输出提示, 区域, 行或列的最大数目
    BIEE安装一直卡在最后一步解决办法
  • 原文地址:https://www.cnblogs.com/riskyer/p/3343295.html
Copyright © 2020-2023  润新知