SharePoint JavaScript show the total items in a library or list   

Tags: SharePoint 2010, General
Technorati Tags: ,

Little script for getting the following result.

image

It will add the total list items of the current library or list in your paging element.

 

Script.

 

/// 
/// 
/// 
/// 
/// 
/// 
/// 
/// 
/// 
 
$(document).ready(function () {
 
    ExecuteOrDelayUntilScriptLoaded(ready, "sp.js");
 
    function ready() {
 
        var listID = SP.ListOperation.Selection.getSelectedList();
 
        if (listID != null) {
            var context = new SP.ClientContext.get_current();
 
            var web = context.get_site().get_rootWeb();
 
            var list = web.get_lists().getById(listID);
 
            context.load(list);
 
            context.executeQueryAsync(function (sender, args) {
 
                var count = list.get_itemCount();
 
                var totaaltext = $(".ms-paging").text() + " / ( " + count.toString() + " )";
 
                $(".ms-paging").text(totaaltext);
 
            }, function (sender, args) { });
        }
    }
});

 

For JavaScript  intellisense in visual studio => SharePoint intellisense for JavaScript in visual studio

 
Posted by  Gilissen Timmy  on  10/25/2011
27  Comments  |  Trackback Url  | 0  Links to this post | Bookmark this post with:        
 

Links to this post

Comments


  commented on  Tuesday, January 24, 2012  3:54 PM 
Why do I btoher calling up people when I can just read this!


xelznpppchk  commented on  Wednesday, January 25, 2012  9:31 AM 
95wocu kwsynllqddjh


zqprldowoyu  commented on  Thursday, January 26, 2012  9:59 AM 
FJqpmU , [url=http://nvhidhsjufdr.com/]nvhidhsjufdr[/url], [link=http://gvveqldzoeqp.com/]gvveqldzoeqp[/link], http://oaqateqvxxbp.com/


snape2k  commented on  Friday, January 27, 2012  4:59 AM 
zovirax cold vwvlb propecia 295 order accutane online %-]


u2bmetub  commented on  Tuesday, January 31, 2012  7:44 AM 
generic provigil >:P to buy propecia bkscf synthroid generic fxuo


abigchild  commented on  Thursday, February 02, 2012  6:11 AM 
topamax 7044 online tamoxifen %-[ levitra 8-DDD


TenruIllusion  commented on  Monday, February 20, 2012  2:54 AM 
HiI read this post 2 times. It is very useful.Pls try to keep posting.Let me show other source that may be good for community.Source: Best regardsJonathan.



danlimbo  commented on  Wednesday, February 22, 2012  4:53 AM 
especially because we can confirm some awesome names speaking that weekend! Evo Terra, the fabulous Amy Donohue, and we even have some local TV news fame speaking- 3-TV?s Carey Pena!  Who would want to miss



dehi  commented on  Thursday, March 29, 2012  11:53 AM 
Hi I do think this article is very useful. Thanks.
but I need more detail to set your script..
please describe the detail of it if you can.


ughbsc  commented on  Thursday, April 05, 2012  2:50 AM 
ughbsc


djqoly http://mypaydayloanscanada.ca/ pay day loan OuwiK payday loans online --> sHagbM [url=http://paydayloans2012.net/cash-advance.html]payday advance[/url] =-]   commented on  Thursday, April 12, 2012  8:35 PM 
djqoly http://mypaydayloanscanada.ca/ pay day loan OuwiK payday loans online sHagbM [url=http://paydayloans2012.net/cash-advance.html]payday advance[/url] =-]


nttcqri  commented on  Thursday, May 03, 2012  12:16 AM 
nttcqri


efnrfy  commented on  Thursday, May 03, 2012  7:02 PM 
efnrfy


pgnfreh  commented on  Friday, May 04, 2012  7:18 PM 
pgnfreh


amvyyt  commented on  Saturday, May 05, 2012  8:52 PM 
amvyyt


eatkvd  commented on  Wednesday, May 09, 2012  3:55 PM 
eatkvd


wldytl  commented on  Thursday, May 10, 2012  8:51 PM 
wldytl


txptrlh  commented on  Friday, May 11, 2012  6:42 PM 
txptrlh


ikcnvo  commented on  Friday, May 11, 2012  9:33 PM 
ikcnvo


kqmwdedh  commented on  Saturday, May 12, 2012  11:42 PM 
kqmwdedh


vtaeyxh  commented on  Monday, May 14, 2012  5:24 PM 
vtaeyxh


gpkumcf  commented on  Monday, May 14, 2012  7:08 PM 
gpkumcf


kogtbnqb  commented on  Tuesday, May 15, 2012  6:21 PM 
kogtbnqb


sscoaah  commented on  Wednesday, May 16, 2012  7:02 PM 
sscoaah


bucgmhx  commented on  Wednesday, May 16, 2012  7:36 PM 
bucgmhx


ngkygxci  commented on  Friday, May 18, 2012  3:39 AM 
ngkygxci


onbkze  commented on  Tuesday, May 22, 2012  3:09 AM 
onbkze

Name *:
URL:
Email:
Comments:


CAPTCHA Image Validation