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 ...
随机推荐
- [C++]memcpy 小记
#include <stdio.h> #include <stdlib.h> #include <string.h> int main () { char a = ...
- muduo源代码分析--我对muduo的理解
分为几个模块 EventLoop.TcpServer.Acceptor.TcpConnection.Channel等 对于EventLoop来说: 他仅仅关注里面的主驱动力,EventLoop中仅仅关 ...
- [Angular 2] *ngFor with index
Let's see how to track index when we use 'ngFor: <li *ngFor="#hero of heros | async, #i = in ...
- Spring下@ResponseBody响应中文内容乱码问题
引言: 在JQuery的Ajax请求中,收到的基于后台返回回来的结果出现乱码,在后台其内容正确,到了前台之后,确是乱码??????,该怎样解决呢? 1. 问题的提出 前端基于JQuery的Ajax进 ...
- Java设计模式---工厂模式(简单工厂、工厂方法、抽象工厂)
工厂模式:主要用来实例化有共同接口的类,工厂模式可以动态决定应该实例化那一个类.工厂模式的形态工厂模式主要用一下几种形态:1:简单工厂(Simple Factory).2:工厂方法(Factory M ...
- USB挂起与唤醒.
USB可见设备状态分为连接(Attached),上电(Powered),默认(Default),地址(Address),配置(Configured)和挂起(Suspended)6个状态.所谓可见,即U ...
- Oracle 分区表中索引失效
当对分区表进行 一些操作时,会造成索引失效. 当有truncate/drop/exchange 操作分区 时全局索引 会失效. exchange 的临时表没有索引,或者有索引,没有用includin ...
- Highcharts使用====一些问题记录
问题1: 图表不显示(但有些浏览器可以显示chrome,IE.火狐不显示),原因可能是前台页面js代码有些问题.highcharts兼容性是比较好的.我遇到的问题是,使用了.replace(/T/, ...
- hihoCoder挑战赛14 A,B,C题解
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud 题目1 : 不等式 时间限制:10000ms 单点时限:1000ms 内存限制:2 ...
- sql_autoload_register() 函数 和__autoload() 的区别
1:__autoload($class) 因为是一个函数,所以只能定义一次,使用多个会冲突报错;而 sql_autoload_register('function') 可定义多个,它有效地创建一个队列 ...