Paging Through Lists

Mar 17, 2010 at 10:55 AM

First off, we're really impressed with SPServices, its changing the way we're developing apps for SharePoint, and we're devising a TimeSheet prototype to use here at the office to see how to use it properly. 

The problem we're having, and I have tried searching - but to no avail, is that we're not getting anywhere with paging, we want to display the last ten time entries for a given user, and allow paging back and forth, so we kick things off with a function that gets the first 10 TimeEntries:

var q="<Query><OrderBy><FieldRef Name='Start' Ascending='FALSE'/></OrderBy><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>"+currentlyViewedUser+"</Value></Eq></Where></Query>";
$().SPServices({
	operation: "GetListItems", 
	async: false, 
	listName: TIME_ENTRIES,		
	CAMLRowLimit: 10,
	CAMLQuery: q,
	CAMLQueryOptions: getQueryOptions(),
	completefunc: function (xData, Status) {
		nextPage = $(xData.responseXML).find("[nodeName=rs:data]").attr("ListItemCollectionPositionNext");
		$(xData.responseXML).find("[nodeName=z:row]").each(function() { renderItemLine($(this)); })}});

With the CAMLQueryOptions set to <QueryOptions><Paging ListItemCollectionPositionNext=""></Paging></QueryOptions> (although this doesn't seem to matter if the CAMLRowLimit is set to less than the number of items returned by the query)

The result is that ListItemCollectioPositionNext is returned as "Paged=TRUE&p_Start=20100315%2009%3a00%3a00&p_ID=1" Which looks to be fine, so the next call is made with this value in the query options - in the form:

<QueryOptions><Paging ListItemCollectionPositionNext="Paged=TRUE&p_Start=20100315%2009%3a00%3a00&p_ID=1"></Paging></QueryOptions>

Which, according to http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems.aspx should be all that we need to do.  But rather than the joy of seeing the next 10 items, Status == "error" and XMLHttpRequest status is 400 and statusText is "Bad Request".

Digging through the XMLHttpRequest I see the wholeText "XML Parsing Error: no element found Location: http://.../List.asmx Line Number 1, Column 1:"

I'm out of ideas, can anyone else suggest what I'm doing wrong?

Thanks in advance, Rob

Coordinator
Mar 17, 2010 at 1:20 PM

Rob:

I'm glad that you are impressed with the library. I do believe that it can help to change the entire approach to development with SharePoint.

I'll be honest that I haven't tested paging with GetListItems.  However, my question back would be whether you should be using the Web Services for this particular piece of functionality or a Data View Web Part (DVWP).  If your goal is to display the last ten time entries for a user, then a DVWP probably makes a lot more sense.  You may be going a layer "too deep" in trying to do this with the Web Services.

M.

Mar 17, 2010 at 2:04 PM

The reason that we're displaying the last ten items is so that the user can page back through their times in order to edit their times - up to two weeks in the past.  In the renderItemLine(...) function, I'm providing an Edit link which will populate a number of elements on the form e.g. Date, Start Time, End Time, Type (Add to times, subtract from times) etc.

We're then using a set of tabs to provide summary views and time calculations per user.

Perhaps it would be better to show a weekly view and use paging based on dates in a CAML query?

Theres no reason that I can see why paging wouldnt work - my bet is that the QueryOptions string is presenting in a corrupt format - is there anyway to check this?

It is becoming obvious at this stage that debugging is the only real weakpoint in this aspect of jQuery programming.

 

Rob

Coordinator
Mar 17, 2010 at 2:31 PM

I agree that paging ought to work, but I still think that if you are just displaying the items a DVWP would make more sense. Or am I missing something?

I'll look at the paging issue, in any case.

M.

Mar 17, 2010 at 2:55 PM

The app has an area where the user can enter date's times and job codes etc.  Under that is the table that we've been asked to be pageable, the reason we have the table is so that the user can click a row to edit it - when they click the row I use JQuery to set the fields ithe date & time area and allow them to make changes and re-submit, I am not sure how this could be achieved using seperate webparts.

It should be relatively easy to set-up a test list and page through it - its something I may have to do once this is delivered.

Coordinator
Mar 17, 2010 at 3:41 PM

Rob:

I can reproduce the issue in my test environment, but I'm still not sure what's going on.  One other thought: What about managing paging on the client side? That would reduce the Web Services calls which might be desirable, anyway.

M.

Mar 17, 2010 at 4:24 PM

Well the plan was to build CAML queries to define the data that was coming out of the WebService - how would you manage paging on the client side, I've produced some CAML (tested on U2U CAML Query Builder) that should allow 7 day pages by me simply adding multiples of 7 to the -nDay(s) values:

<Query>
	<Where>
		<And>
			<And>
				<Leq><FieldRef Name='Start' /><Value Type='DateTime'>[Today-0Day(s)]</Value></Leq>
				<Geq><FieldRef Name='Start' /><Value Type='DateTime'>[Today-7Day(s)]</Value></Geq>
			</And>
				<Eq><FieldRef Name='Title' /><Value Type='Text'>DOMAIN\robh</Value></Eq>
		</And>
	</Where>
	<OrderBy><FieldRef Name='Start' Ascending='False' /></OrderBy>
</Query>

But this doesn't return anything...  I do get something if I use the query below - so it looks like there might be some issues around the DateTimes

 

<Query>
  <OrderBy><FieldRef Name='Start' Ascending='FALSE'/></OrderBy>
  <Where>
    <Eq><FieldRef Name='Title'/><Value Type='Text'>DOMAIN\robh</Value></Eq>
  </Where>
</Query>

Because the following query works in U2U but not though my JavaScript code

 

<Query>
  <Where>
    <Leq><FieldRef Name='Start' /><Value Type='DateTime'>[17/03/2010 15:57:38-7Day(s)]</Value></Leq>
  </Where>
</Query>

Cheers for your help so far.


Rob

Coordinator
Mar 17, 2010 at 5:32 PM

Rob:

The dates piece is easier.  You can use OffsetDays in your CAML:

<Leq><FieldRef Name='Start' /><Value Type='DateTime'><Today OffsetDays="-1" /></Value></Leq>

Positive numbers go forward, negative back.

On the paging, if you call the Web Service with CAMLRowLimit: 0, you'll get back all of the items which match your criteria.  At that point, you effectively have a local cache of the items from the server.  Based on user activity you can choose which items you want to display.  As I said earlier, this cuts down on the number of Web Services calls, so it might be a good idea, anyway.  It does assume that the items won't get "dirty" while the user has the page open.

M.

Mar 17, 2010 at 10:29 PM

Mark,

I will give the OffsetDays code a try first thing.

I was originally doing limited queries and chopping out the data, but was concerned with the size of the returned data - I am probably worrying unduly but as a rule I try to balance the processing between a Service and its client.

Thanks

Rob

Coordinator
Mar 18, 2010 at 3:10 AM

You're totally thinking the right way on the server / client trade-offs.  From the sounds of it, though, you're just displaying the timesheets for one individual.  The number of those couldn't be that high, could it?  A few dozen?

M.

Mar 18, 2010 at 9:37 AM
Edited Mar 19, 2010 at 9:23 AM

Well it looks like SP has forced a trade off, the ability to page through dates with the string

<Query><Where><And><Leq><FieldRef Name='Start' /><Value Type='DateTime'><Today OffsetDays='0' /></Value></Leq><Geq><FieldRef Name='Start' /><Value Type='DateTime'><Today OffsetDays='-7' /></Value></Geq></And></Where></Query>

Returns a useable set - but with all employees, but alas narrowing the search down using

<Query><Where><And><And><Leq><FieldRef Name='Start' /><Value Type='DateTime'><Today OffsetDays='0' /></Value></Leq><Geq><FieldRef Name='Start' /><Value Type='DateTime'><Today OffsetDays='-7' /></Value></Geq></And><Eq><FieldRef Name='Title' /><Value Type='Text'>DOMAIN\robh</Value></Eq></And></Where><OrderBy><FieldRef Name='Start' Ascending='False' /></OrderBy></Query>

Returns an empty list, yet each element works on its own, and the query works in the U2U query tool, we know that the format is correct, as it returns an empty set rather than an error.

Looking through your library it is not obvious that the string is changed in any way, it points towards something like JavaScript to Service formatting issue - or something is amiss with the service - although the strings work in U2U's query tool.

The timesheet app will be rolled out to several hundred people - so in the first instance the smallest set is going to be the times for one person.  But in a year there are going to be hundreds of time entries so it would be better to narrow the search by date range, then filter out the people.

Either way, we can still move forward with what we're doing.

Cheers

Rob

 

Coordinator
Mar 18, 2010 at 11:46 AM

Is Title the right column to be checking for the user account?

M.

Mar 18, 2010 at 11:55 AM

At the moment - it is!

Unless you wish to warn me against it!

Coordinator
Mar 18, 2010 at 12:33 PM

Yes, I would warn against it.  You should use columns for thier intended use, as well as column types.  A "user" should be represented by a Person or Group column.  In fact, in this case, you probably want to filter be the Created By column (Author).  This will always contain the person who created the item.

M.

Mar 31, 2010 at 10:11 PM
Edited Mar 31, 2010 at 10:48 PM
Hi, if you still need it, this is something that worked for me, works good when you want to step through a long list - returning all rows might be a bit slow.... /Fredrik
function displayResult(listName, next)
{	
	try{
		next = next.replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
	}
	catch(e){
	}
	$().SPServices({
		operation: "GetListItems",
		listName: listName,
		webURL: siteURL,
		CAMLQueryOptions: '<QueryOptions><Paging ListItemCollectionPositionNext="'+next+'" /></QueryOptions>',
		CAMLRowLimit: "10",
		completefunc: function (xData, Status) {
			//YourOutputCodeHere
			var next=$(xData.responseXML).find("rs\\:data").attr("ListItemCollectionPositionNext");
			$("#WSOutput").html("").append('<a href="javascript:displayResult(\''+listName+'\', \''+next+'\')">Next</a>');
		}
	});
}
Apr 16, 2011 at 3:03 AM

Hi fereko,

is it possible to see your entire code? I'm trying to wrap my head around use of pagination and would like to see how have you accomplished this.

 

May 2, 2011 at 11:27 PM

Hi,

you just call the function above on load with 

displayResult('yourListName')

and keep a div with the ID WSOutput to put the "Next"-link. Appart from that, just use it as any other GetListItems call.

With a little bit more coding this works very good using a facebook/disqus style list, automatically loading new items when reaching the bottom of the page.

Jun 25, 2012 at 7:49 AM

Thanks a lot fereko for this, worked perfectly for me!. only one problem. I have both previous and next. My previous is always going to the first page. Can anybod help.

 function displayResult(listName, next,from)
{	


 
        var strHTML_CUpdates;
        var ViewFields_CUpdates = "<ViewFields><FieldRef Name='Title' /><FieldRef Name='ActionType' /><FieldRef Name='Description' /><FieldRef Name='ArticleID' /><FieldRef Name='ID' /><FieldRef Name='ParentUser' /><FieldRef Name='Author' /><FieldRef Name='GroupName' /></ViewFields>";   
        var Query_CUpdates="<Query><OrderBy><FieldRef Name='Created' Ascending='False' /></OrderBy></Query>";
        strHTML_CUpdates="<div class=\"content\"><ul class=\"dottedLineList\">";
        var URL_TalkCentral="http://groupworldportal/gw/community/Pages/mypostdetails.aspx?postid=";
        var URL_Recipe="http://groupworldportal/gw/community/Pages/recipedetail.aspx?pid=";
        var URL_TravelReview="http://groupworldportal/gw/travel/Pages/mypostdetails.aspx?postid=";   
       	$("#log").append("Next: "+next+"<br/>");
		$("#log").append("Previous: "+Previous+"<br/>");
        

                     
	try{
		next = next.replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/</g,'&lt;').replace(/>/g,'&gt;');		
		Previous = Previous.replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/</g,'&lt;').replace(/>/g,'&gt;');		
	
		
	}
	catch(e){
	}
	var QueryOptions="";	
	
	if(from=='P')
	{QueryOptions='<QueryOptions><Paging ListItemCollectionPositionNext="'+Previous+'" /></QueryOptions>';}
	else
	{QueryOptions='<QueryOptions><Paging ListItemCollectionPositionNext="'+next+'" /></QueryOptions>';}
	
	$().SPServices({
		operation: "GetListItems",
            listName: listName,
            webURL:"http://groupworldportal/gw/community/",
            CAMLViewFields :ViewFields_CUpdates,
            CAMLQuery: Query_CUpdates,
            CAMLQueryOptions:QueryOptions,
            CAMLRowLimit: "3",
            completefunc: function (OHHomeData, Status) {
			//YourOutputCodeHere
			//$("#xxml").text(OHHomeData.responseText);
			 Previous = next;
			 next=$(OHHomeData.responseXML).find("rs\\:data").attr("ListItemCollectionPositionNext");
			
			$("#WSOutput").html("").append('<a href="javascript:displayResult(\''+listName+'\', \''+Previous+'\',\'P\')">Previous</a> | <a href="javascript:displayResult(\''+listName+'\', \''+next+'\',\'N\')">Next</a>');
			
			
			
			    $(OHHomeData.responseXML).find("[nodeName=z:row]").each(function(){                                  
            
                var  strAuthor = $(this).attr("ows_Author").substring($(this).attr("ows_Author").indexOf("#")+1,$(this).attr("ows_Author").length);   
                var strID= $(this).attr("ows_ArticleID");
                
                 switch($(this).attr("ows_GroupName"))
             { 
                case "Talk Central":
                URL=URL_TalkCentral+strID;
                break;
                case "Travel Review":
                URL=URL_TravelReview+strID;
                break;
                case "Recipe":
                URL=URL_Recipe+strID;
                break;                 
             }
                
             switch($(this).attr("ows_ActionType"))
             {                                          
             case "REPLYTOCOMMENT":                              
              strHTML_CUpdates+="<li><label>&raquo; </label>"+strAuthor+" has replied to "+$(this).attr("ows_ParentUser")+" <a href='"+URL+"'>comment</a></li>";
              break;
              case "Post":
              strHTML_CUpdates+="<li><label>&raquo; </label>"+strAuthor+" has posted a new article on "+$(this).attr("ows_GroupName")+" titled <a href='"+URL+"'>"+$(this).attr("ows_Title")+"</a></li>";
              break;
              case "Comment":
        strHTML_CUpdates+="<li><label>&raquo; </label>"+strAuthor+" has  commented on "+$(this).attr("ows_ParentUser")+" 's <a href='"+URL+"'>post</a></li>";
              break;
             }                  

            
            });
        
            strHTML_CUpdates+="</ul></div>" ;
           $("#cUpdates").html(strHTML_CUpdates);
			
			
			
			
			
		}
	});
}
Aug 6, 2012 at 3:13 PM

janeshh,

Did you find the a solution for your problem for the next/previous and paging across pages for SPServices? I am still working on this and looking for a solution. If you have any more progress or a proper solutions please let me know what you did.

 

Aug 7, 2012 at 4:13 AM

Hi demaximus,

Yes i managed to fix the issue. Will post the full code in a while.

 

Thanks

Janesh

 

Aug 7, 2012 at 6:55 AM
    <style type="text/css">    

.gallery-item img
{
 height: 100px;
 width: 320px;
 float: left;
 margin-right: 5px;
 margin-bottom: 5px;
}
#gallery-pager-controls
{
 clear: both;
}
#gallery-pages div
{
 float: left;
 margin-right: 5px;
}
 .brochures
    {
        float: left; 
        padding: 0px; 
        margin: 6px 6px 6px 6px; 
        border-style: solid; 
        border-width: 0px; 
        border-color: #DDDDDD;
        vertical-align: middle; 
        text-align: center; 
        width:320px;
    }    
    
.selected
{
    color:gray !important;
    text-decoration:none !important;
    cursor:default;
}
</style>

    <script type="text/javascript" language="javascript">
    
    var rowLimit = 10;
    var list = "Random Banners";
    var query = "";
    var targetID = "Random Banners";
    var weburl = "http://groupworldportal/gw/";      //http://groupworldportal/gw/our_company/ekgroup/cc/
    var rootSite = "http://groupworldportal/";
    var pos="";
    var iCounter = 0;
    var pages = 0;
    var brochureLink = "";
    var htmlBlock = "";
    var href = "";
    var nClickedPage = 0;
    
    //var swfFile = "/gw/our_company/PublishingImages/Banners/banner_basra.swf";
    
    var swfHtmlBlock ="";
        
    $(document).ready(function()
    {
        GetBanners();
        BuildNav();
        UpdatePrevNext();
    });
    
    function GetBanners(pos)
    {    
        $("#gallery").html("");
        
        try
        {            
		    pos = pos.replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/</g,'&lt;').replace(/>/g,'&gt;');		    
        }
        catch(e)
        { }
    
        $().SPServices({
        webURL: weburl,
        operation: "GetListItems",
        async: false,
        listName: list,
        CAMLQuery: query,
        CAMLViewFields: "<ViewFields><FieldRef Name='ID' /><FieldRef Name='FileRef'/></ViewFields>",
   	    CAMLQueryOptions: "<QueryOptions><Paging ListItemCollectionPositionNext='" + pos + "' /></QueryOptions>",
        CAMLRowLimit: rowLimit,
        completefunc: function (xData, Status) 
        {            
            iCounter = 0;
            htmlBlock = "";
            htmlBlock = "<table width='680' style='border:solid 1px #DDDDDD;padding:10px;'><tr valign='top'>";
	        $(xData.responseXML).find("[nodeName='z:row']").each(function(i)
	        {         	        
      	        var id = $(this).attr("ows_ID");
      	        href = $(this).attr("ows_FileRef");      	        
      	        href = rootSite + href.substring(href.indexOf("#")+1);
         
      	        
    swfHtmlBlock = "<object id='OBJ_" + id +"' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' >";
    swfHtmlBlock += "<param name='_cx' value='8255'><param name='_cy' value='2117'><param name='FlashVars' value=''>";
    swfHtmlBlock += "<param name='Movie' value='"+ href +"'>";
    swfHtmlBlock += "<param name='Src' value='"+ href +"'>";
    swfHtmlBlock += "<param name='WMode' value='Window'><param name='Play' value='-1'>";
    swfHtmlBlock += "<param name='Loop' value='-1'><param name='Quality' value='High'><param name='SAlign' value=''>";
    swfHtmlBlock += "<param name='Menu' value='-1'><param name='Base' value=''><param name='AllowScriptAccess' value=''>";
    swfHtmlBlock += "<param name='Scale' value='ShowAll'><param name='DeviceFont' value='0'><param name='EmbedMovie' value='0'>";
    swfHtmlBlock += "<param name='BGColor' value=''><param name='SWRemote' value=''><param name='MovieData' value=''>";
    swfHtmlBlock += "<param name='SeamlessTabbing' value='1'><param name='Profile' value='0'><param name='ProfileAddress' value=''>";
    swfHtmlBlock += "<param name='ProfilePort' value='0'><param name='AllowNetworking' value='all'>";
    swfHtmlBlock += "<embed src='"+ href +"' quality='high'";
    swfHtmlBlock += "pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'";
    swfHtmlBlock += "type='application/x-shockwave-flash' width='312' height='80'></embed></object>";
      	              	        
                if (iCounter%2==0)
                {   
                    if (iCounter != rowLimit)
                    {
                        htmlBlock += "</tr><tr>";
                    }                  
                    htmlBlock += "<td><div class='brochures'>"+ swfHtmlBlock +"</div></td>";
                }
               else
               {
                  htmlBlock += "<td><div class='brochures'>" + swfHtmlBlock + "</div></td>";     
               }
               
               iCounter++;
    
            outputHTML = htmlBlock + "</tr></table>";
    		
      });
      $("#gallery").append(outputHTML);
    }
  });
    }
    
    </script>
    
    <script type="text/javascript" language="javascript">
    
    function BuildNav()
    {
        $("gallery-prev a").unbind('click');
        $("gallery-next a").unbind('click');
        $(".pager a").unbind('click');
        
        $("gallery-pages").html("");
        
        var totalItems = 0;
	    var firstPos = "";
	    
	    $().SPServices({
	        webURL: weburl,
		    operation: "GetListItems",
		    async: false,
		    listName: list,
		    CAMLQuery: query,
		    CAMLViewFields: "<ViewFields><FieldRef Name='ID' /></ViewFields>",
		    completefunc: function (xData, Status)
		    {
			    totalItems = $(xData.responseXML).find("[nodeName='rs:data']").attr("ItemCount");			    
		    }
	    });
	    
	    $().SPServices({
	        webURL: weburl,
		    operation: "GetListItems",
		    async: false,
		    listName: list,
	        CAMLQuery: query,
		    CAMLViewFields: "<ViewFields><FieldRef Name='ID' /></ViewFields>",
		    CAMLRowLimit: rowLimit,
		    completefunc: function (xData, Status)
		    {
			    firstPos = $(xData.responseXML).find("[nodeName='rs:data']").attr("ListItemCollectionPositionNext");			    
		    }
	    });	
	    
	  
	    
	    if (eval(totalItems > rowLimit))
	    {
	        $("#gallery-pages").append('<div id=\'gallery-prev\'><a href="#">Prev</a></div>');
	        
            pages = Math.ceil(totalItems / rowLimit);
		    var nextPos = "";
		    		    
		    for(i=1;i<=pages;i++)
		    {		        
			    if(i==1)
			    {			        
				    $("#gallery-pages").append("<div id='row-" + i + "' class='pager'><a class='selected' href='javascript:GetBanners(\"\",\"" + rowLimit + "\")'>" + i + "</a></div>");
				    nextPos = firstPos;
				    $("#gallery-prev a").addClass("selected");
				    
			    }
			    else
			    {
				    if(i==2)
				    {				        
					    $("#gallery-pages").append("<div id='row1-"+ i +"' class='pager'><a href='javascript:GetBanners(\"" + firstPos + "\",\"" + rowLimit + "\")'>" + i + "</a></div>");
		            
				    }
				    else
				    {
					    nextPos = GetNextPos(nextPos, rowLimit);
					    $("#gallery-pages").append("<div id='row2-"+ i +"' class='pager'><a href='javascript:GetBanners(\"" + nextPos + "\",\"" + rowLimit + "\")'>" + i + "</a></div>");		                
				    }
			    }
		    }
		    
		    $("#gallery-pages").append('<div id=\'gallery-next\'><a href="#">Next</a></div>');		    		    		    
	    }
    }
    
    </script>


<script language="javascript" type="text/javascript">

function UpdatePrevNext()
{    
    $(".pager a").click(function()
    {   
		$(".pager a").removeClass("selected");
		var id = $(this).parent().attr("id");
		id = id.substring(id.indexOf('-')+1)		
		$(this).addClass("selected");
		//$(this).css("text-decoration:underline;");
		//$(this).bind('click',disabler);
		
		if (eval(id) == 1)
		{
		    $("#gallery-prev a").addClass("selected");
		}
		else
		{
		    $("#gallery-prev a").removeClass("selected");		    		    
		}
		
		if (eval(id) == pages)
		{   
		    $("#gallery-next a").addClass("selected");
		}
		else
		{		    
		    $("#gallery-next a").removeClass("selected");
		}
	});
	
	
	$("#gallery-prev a").click(function(e)
	{
		e.preventDefault();
		
		var id = $(".pager a.selected").parent().attr("id");
		id = id.substring(id.indexOf('-')+1);
		
		if(id != 1)
		{
			$(".pager").eq(id-2).find("a").click();
			var href = $(".pager").eq(id-2).find("a").attr("href");
			
			href = href.substring(href.indexOf('\"'),href.length-1);
			
			href = href.split(',');
			var page = href[0].substring(1,href[0].length-1);
			
			var rowLimit = href[1].substring(1,href[1].length-1)
			GetBanners(page,rowLimit);
		}
		
		if (eval(id)-1 == 1)
		{  
		     $(this).unbind('click',disabler);
		}
		
		
//		
//		total = $(".pager").length;		
//		var nCount = eval(id) + 1;
//		
//		//alert(total + "     " + nCount);
//		if (nCount != total)
//		{    
//		     //$("#gallery-next a").unbind('click',disabler);		     
//		}
		
	});
	
	$("#gallery-next a").click(function(e){
		e.preventDefault();
		
		var id = $(".pager a.selected").parent().attr("id");
		id = id.substring(id.indexOf('-')+1);		
		total = $(".pager").length;
		
		var nCount = eval(id) + 1;				

		    if(id != total)
		    {
			    $(".pager").eq(id).find("a").click();
    	
			    var href = $(".pager").eq(id).find("a").attr("href");
			    href = href.substring(href.indexOf('\"'),href.length-1);
			    href = href.split(',');
			    var page = href[0].substring(1,href[0].length-1);
    			
			    var rowLimit = href[1].substring(1,href[1].length-1)
			    GetBanners(page,rowLimit);		    			    
		    }
      });
}


function disabler(event)
{
    event.preventDefault();
    return false;
}

function GetNextPos(pos, rowLimit, query)
{
	try
	{
		pos = pos.replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
	}
	catch(e)
	{ }

	$().SPServices({
	    webURL: weburl,
		operation: "GetListItems",
		async: false,
		listName: list,
		CAMLQuery: query,
		CAMLQueryOptions: "<QueryOptions><Paging ListItemCollectionPositionNext='" + pos + "' /></QueryOptions>",
		CAMLRowLimit: rowLimit,
		completefunc: function (xData, Status) {
			pos = $(xData.responseXML).find("[nodeName='rs:data']").attr("ListItemCollectionPositionNext");
		}
	});

return pos;
}

</script>

</head>
<body>
<h2>Banners</h2><br /><br />
    <div id="gallery">
    </div>
    <div id="gallery-paper-controls">
        <div id="gallery-pages">
        </div>
    </div>
</body>
Aug 13, 2012 at 9:15 PM

Thanks Janesh, helped a lot.

regards

Aug 16, 2012 at 6:52 AM

Hi demaximus,

We found some major performance issues with the above code, unfortunatley some logical error and its calling the server many times in a loop(Thanks to fiddler). Hope you got some idea with the above code.

 

We are fixing the issues and will post the final optimized one soon

Regards

 

Feb 12, 2013 at 7:21 PM
janeshh wrote:
Hi demaximus, We found some major performance issues with the above code, unfortunatley some logical error and its calling the server many times in a loop(Thanks to fiddler). Hope you got some idea with the above code.   We are fixing the issues and will post the final optimized one soon Regards  
janeshh,

any update on this?

~S.
Feb 13, 2013 at 2:53 AM
MR_Sanderson,

Yes we managed to fix the issue, will reply with the full code today itself,


Thanks
Janesh
Apr 10, 2013 at 9:44 PM
Thanks Janesh,
.replace(/&/g,'&').replace(/"/g,'"').replace(/</g,'<').replace(/>/g,'>');

helped a lot!