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;width:10%;background-color:gray;color:white;width:30px;height:30px;text-align:center;'>" + arrValue + "</div>");
}); } function onQueryFailed(sender, args) { alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
} </script>

Display number of replies in disscussion board的更多相关文章

  1. Codeforce 835B - The number on the board (贪心)

    Some natural number was written on the board. Its sum of digits was not less than k. But you were di ...

  2. Codeforces Round #427 (Div. 2) Problem B The number on the board (Codeforces 835B) - 贪心

    Some natural number was written on the board. Its sum of digits was not less than k. But you were di ...

  3. Codeforces Round #427 (Div. 2) B. The number on the board

    引子: A题过于简单导致不敢提交,拖拖拉拉10多分钟还是决定交,太冲动交错了CE一发,我就知道又要错过一次涨分的机会.... B题还是过了,根据题意目测数组大小开1e5,居然蒙对,感觉用vector更 ...

  4. [初级教程]用SecureCRT+Xming轻松远程实现Linux的X DISPLAY

    [初级教程]用SecureCRT+Xming轻松远程实现Linux的X DISPLAY 发布者:sqqdugdu 时间:10-06 阅读数:2117 测试环境:RHEL 6.1,SecureCRT 5 ...

  5. System Board Replacement Notice

    System Board Replacement Notice System Board Replacement Notice for TP 770E and TP 600 Restoring the ...

  6. 微信小程序 项目实战(二)board 首页

    1.项目结构 2.页面 (1)数据(逻辑) board.js // pages/board/board.js Page({ /** * 页面的初始数据 */ data: { imgWrap: [] } ...

  7. 一个ICMP单元

    unit ICMPUtils; interface {$IFDEF VER80} { This source file is *NOT* compatible with Delphi 1 becaus ...

  8. Tic-Tac-Toe游戏

    #Tic-Tac-Toe #机器人和人类下井字棋 #全局变量 import random X = "X" O = "O" EMPTY = " &quo ...

  9. 设备管理 USB ID

    发现个USB ID站点,对于做设备管理识别的小伙伴特别实用 http://www.linux-usb.org/usb.ids 附录: # # List of USB ID's # # Maintain ...

随机推荐

  1. SQL Server 各任务所维护

    SQL Server 正在运行的代码查看 SELECT [Spid] = session_id , ecid , [Database] = DB_NAME(sp.dbid) , [User] = nt ...

  2. 数据库和linq中的 join(连接)操作

    sql中的连接 sql中的表连接有inner join,left join(left outer join),right join(right outer join),full join(full o ...

  3. int与Integer

    int 是基本类型,直接存数值 integer是对象,用一个引用指向这个对象 1.Java 中的数据类型分为基本数据类型和复杂数据类型 int 是前者>>integer 是后者(也就是一个 ...

  4. vi & vim 基本指令(持续更新ing)

    Abstract:1) 文本编辑模式:                      --INSERT--2)一般模式:                      --i.o.a.R--3)命令行命令模式 ...

  5. 在浏览器中就可以写F#程序了,你试试吧

    学习F#有一种简单办法,不需要安装Visual Studio,在浏览器中就可以写F#了,非常方便,进入下面的链接,你可以试试. http://www.tryfsharp.org/Learn

  6. 在OC中调用Swift类中定义delegate出现:Property 'delegate' not found on object of type ...

    找了许久没找到答案, 在下面的链接中, 我解决了这个问题: http://stackoverflow.com/questions/26366082/cannot-access-property-of- ...

  7. C#构造函数使用

    作用:帮助我们初始化对像(给对像的每个属性依次的赋值) 构造函数是一个特殊的方法 1.构造函数没有返回值,连void也不能写 2.构造函数名称要和类名一样 3.创建对像时会执行构造函数 4.构造函数可 ...

  8. ie6下:png图片不透明 和 背景图片为png的节点的内部标签单击事件不响应

    1.png图片不透明 少量图片时:使用滤镜: _background:none; _filter:prodig:DXImageTransform.Microsoft.AlphaImageLoader( ...

  9. struts2中<s:select/>标签的运用详解

    <s:select list="smsTypes" listKey="SmsTypeId" listValue="SmsTypeName&quo ...

  10. LBS配置

    js: <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak= ...