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 ...
随机推荐
- AxisFault另外一个问题
出现以下情况,能够是proxy.setEndpoint(endpoint);中endpoint不正确导致 因该是:endpoint = http://127.0.0.1/8080/项目名/servic ...
- 经常使用的自己定义UI组件- 一:TimeView
近期做蛋疼的机顶盒项目,以后遇到哪些经常使用的组件,记录于此. 反编译 youku视频TV偷来的..也希望各位童鞋多学习别人的代码,为己所用. 当然还有其它的办法,比方监听系统发出的广播等等.等 ...
- ViutualBox虚拟机里添加磁盘
1.首先在VirtualBox界面给虚拟机添加一块磁盘 2. 启动系统,查看当前磁盘空间 Last login: Tue Mar 15 22:24:47 2016 from 192.168.1.100 ...
- Python-xml解析常用方法简介
[XML几种解析方法] 常见的XML编程接口有DOM和SAX,这两种接口处理XML文件的方式不同,使用场合自然也就不同. Python有三种方法解析XML: SAX,DOM,以及ElementTree ...
- error BC31019 无法写入输出文件 未指定错误
今天获取项目最后版本后,编译突然出现错误 error BC31019 无法写入输出文件 "xxx目录" 未指定错误 试着调整当前用户对这个文件的读写权限等各种方法,都未能解决该问题 ...
- 最全C语言笔记回顾
- 武汉科技大学ACM :1009: 零起点学算法63——弓型矩阵
Problem Description 输出n*m的弓型矩阵 Input 多组测试数据 每组输入2个整数 n和m(不大于20) Output 输出n*m的弓型矩阵,要求左上角元素是1,(每个元素占2个 ...
- Floyed算法 最短路径
#include<iostream>#include<cstdio>int v,e,n; //v是顶点数,e是条数int v1[101][101],path[101][101] ...
- SpringMVC项目中中文字符乱码问题及解决办法总结(非专业最优解决办法) -- ajax传值乱码; request.getParameter()乱码;
情况一: ajax中传值时是乱码(后台可以获取到中文字符,但用@ResponseBody返回时前台为乱码) 情况二: Controller 中 request.getParameter()获取到的是乱 ...
- mybatis常用语句
<trim>标签中,prefix 前缀,suffix后缀, suffixOverrides语句最后如果有指定符号,则去除此符号, prefixOverrides语句最前面如果有指定符号,则 ...