DataTables logo DataTables

via Ad Packs
Pagination not enabled
  • SyGENSyGEN
    Posts: 4
    Hi,

    First of all, I'd like to thank the author of this magnific tool !
    Nevertheless, I have a small prob with pagination icons not enabling.

    I have set up as in demo for server-side the tool like this :
    			$(document).ready(function() {
    				$('#example').dataTable( {
    					"bProcessing": true,
    					"bServerSide": true,
    					"sAjaxSource": "dsp_search.cfm",
    					"bPaginate": true
    				} );
    			} );
    

    the returned JSON gives me this
    [code]
    {"sEcho":10,"aaData":[[1000,"ACQUISITION DE COMPETENCES","AN","ACT"],[1000,"Action de commercialisation de produits du terroir","AN","ACT"],[1000,"APPUI TECHNIQUE","AN","ACT"],[1000,"Appui Technique","AN","ACT"],[1000,"APPUI TECHNIQUE","AN","ACT"],[1000,"Appui technique GAL","AN","ACT"],[1000,"Arch
  • SyGENSyGEN
    Posts: 4
    FYI, here is the working (but those icons) coldfusion code i wrote to generate my datas and that could help CF developers to integrate your tool softly. (I saw lot's of complicated CF stuff in this forum as it can be done more easily when using CF >= 8 versions)

    <cfprocessingdirective suppresswhitespace="yes">
    
    	<cfsilent>           
    	
    	    <cfset dsn = "mydsn">	    
    	    <cfset tmp = StructNew()>
    	    <cfset dArray = ArrayNew(1) >	    
    	    <cfset columnArray = ["levelid", "titre", "categorie", "statut"]>
    	    <cfset columnList = ArrayToList(columnArray)> 
    	    
    	    <cfset searchField = "titre">
    	    <cfparam name="url.iDisplayStart" default="0">
    	    <cfparam name="url.iDisplayLength" default="10">
    	    <cfparam name="url.sEcho" default="10">	    	    
    	    
    			<cfquery name="thm" datasource="#dsn#">
    			   SELECT 
    			   				#columnList#
    			   FROM 
    			   				DOCUMENTS
    			   <cfif isdefined('url.sSearch')>
    			   WHERE
    			   		  	#searchField# LIKE <cfqueryparam value="%#url.sSearch#%" cfsqltype="cf_sql_varchar">
    			   </cfif>
    			   
    			   LIMIT 
    			   		<cfqueryparam value="#url.iDisplayStart#" cfsqltype="cf_sql_numeric">,
    			   		<cfqueryparam value="#url.iDisplayLength#" cfsqltype="cf_sql_numeric">
    			</cfquery>  
    			
    			<cfquery name="total" datasource="#dsn#">
    				SELECT
    								count(docid) rownbr
    				FROM
    								DOCUMENTS
    			</cfquery>
    			
    			<!--- Generate JSON from Query --->    
    	    <cfloop query="thm">
    	    		<cfset dArrayTmp = ArrayNew(1)>
    	    		<cfloop array="#columnArray#" index="i">	    		
    								<cfset ArrayAppend(dArrayTmp,evaluate("thm.#i#"))>
    	    		</cfloop>
    					<cfset ArrayAppend(dArray,dArrayTmp) >
    	    </cfloop> 
    	    
    	    <cfset tmp.sEcho = javacast('int',url.sEcho)>
    	    <cfset tmp.iTotalRecords = total.rownbr>
    	    <cfset tmp.iTotalDisplayRecords = total.rownbr>
    	    <cfset tmp.aaData = dArray>
    	   
    	    <cfset tmpSOut = SerializeJSON(tmp)>
    	    <!--- Since SerializeJSON capitalize the content which is case-sensitive let's reset it the correct way --->
    	    <cfset tmpSOut = Replace (tmpSOut,'SECHO','sEcho','one')>
    	    <cfset tmpSOut = Replace (tmpSOut,'ITOTALRECORDS','iTotalRecords','one')>
    	    <cfset tmpSOut = Replace (tmpSOut,'ITOTALDISPLAYRECORDS','iTotalDisplayRecords','one')>
    	    <cfset tmpSOut = Replace (tmpSOut,'AADATA','aaData','one')>
    	    
    	</cfsilent>
    	
    	<cfoutput>#tmpSOut#</cfoutput>
    	
    </cfprocessingdirective>
    
  • allanallan
    Posts: 15,551
    iTotalDisplayRecords is the total number of records in the data set after filtering - not just aData.length (which DataTables can do itself!). So if you have no filtering iTotalDisplayRecords should be exactly the same as iTotalRecords: http://www.datatables.net/usage/server-side

    Allan
  • SyGENSyGEN
    Posts: 4
    Thanks a lot, I just skipped this little detail. Working perfectly now.
  • allanallan
    Posts: 15,551
    Good stuff :-)

    I've added this as an FAQ now: "Pagination is not enabled, or the information text shows the wrong data set count" - http://datatables.net/faqs

    Allan
  • SyGENSyGEN
    Posts: 4
    Cool ;)

    I've edited the code above so everyone can use it as is (of course with dsn & table changes).
    Now let's start trying the pipelining in CF. If I succeed, i'll post it here too.
This discussion has been closed.
← All Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Support

Get useful and friendly help straight from the source.

In this Discussion