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;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的更多相关文章
- 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 ...
- 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 ...
- Codeforces Round #427 (Div. 2) B. The number on the board
引子: A题过于简单导致不敢提交,拖拖拉拉10多分钟还是决定交,太冲动交错了CE一发,我就知道又要错过一次涨分的机会.... B题还是过了,根据题意目测数组大小开1e5,居然蒙对,感觉用vector更 ...
- [初级教程]用SecureCRT+Xming轻松远程实现Linux的X DISPLAY
[初级教程]用SecureCRT+Xming轻松远程实现Linux的X DISPLAY 发布者:sqqdugdu 时间:10-06 阅读数:2117 测试环境:RHEL 6.1,SecureCRT 5 ...
- System Board Replacement Notice
System Board Replacement Notice System Board Replacement Notice for TP 770E and TP 600 Restoring the ...
- 微信小程序 项目实战(二)board 首页
1.项目结构 2.页面 (1)数据(逻辑) board.js // pages/board/board.js Page({ /** * 页面的初始数据 */ data: { imgWrap: [] } ...
- 一个ICMP单元
unit ICMPUtils; interface {$IFDEF VER80} { This source file is *NOT* compatible with Delphi 1 becaus ...
- Tic-Tac-Toe游戏
#Tic-Tac-Toe #机器人和人类下井字棋 #全局变量 import random X = "X" O = "O" EMPTY = " &quo ...
- 设备管理 USB ID
发现个USB ID站点,对于做设备管理识别的小伙伴特别实用 http://www.linux-usb.org/usb.ids 附录: # # List of USB ID's # # Maintain ...
随机推荐
- ajax取返回值的方法
var check_res; //ajax核对手机验证码 function smsverify(){ var ajaxurl = APP_ROOT+"/index.php?ctl=ajax& ...
- iOS--九宫格布局
[self rankWithTotalColumns: andWithAppW: andWithAppH:]; //九宫格布局 - (void)rankWithTotalColumns:(int)to ...
- (转)keytools命令
结合网络资源,对keytool使用总结,以备后用: Keytool是一个Java数据证书的管理工具 ,Keytool将密钥(key)和证书(certificates)存在一个称为keystore的文件 ...
- 深入解读ESB与SOA的关系
时至今日,SOA的概念渐渐清晰了. 有关ESB的概念,已经吵了好多年了,还是没有定论. 我个人认为,ESB本来就是抽象的概念,而且内涵丰富,在不同的场合含义不同.因此应该从不同的角度来认识. ...
- 3D空间包围球(Bounding Sphere)的求法
引言 在3D碰撞检測中,为了加快碰撞检測的效率,降低不必要的碰撞检測,会使用基本几何体作为物体的包围体(Bounding Volume, BV)进行測试.基本包围体的碰撞检測相对来说廉价也easy的多 ...
- python数据库做成邮箱的注册系统!
#! /usr/bin/env python2.7 # -*- coding:utf-8 -*- #File:w7.py #Date:2013-7-18 #Author:wangyu import r ...
- Android应用调试经常使用知识
1.Android应用启动过程调试 1).进入设置-->辅助功能-->开发人员选项:假设没有打开开发人员模式.在拨号里面输入*#*#6961#*#*: 2).找到选择调试应用,打开选择你要 ...
- 50个android开发技巧
50个android开发技巧 http://blog.csdn.net/column/details/androidhacks.html
- Linux的VI/VIM
参考自:http://www.cnblogs.com/itech/archive/2009/04/17/1438439.html 作者:iTech 出处:http://itech.cnblogs.co ...
- css float父元素高度塌陷
css float父元素高度塌陷 float 使父元素高度塌陷不是BUG,反而是标准. float 原本是为了解决文字环绕才出现的. 当然有的时候要解决高度塌陷的问题 以下几个方法可以解决float ...