trying to get the datatables to use sql pagination...
# cfml-beginners
g
trying to get the datatables to use sql pagination here is what i am getting from DB i was reading some blogs and the datatables using this technique is done somewhere, i am just in rush so great if helpful if someone can point to a tutorial
p
What database engine? They all do pagination differntly.
g
i am doing sql server
p
What year is the sever? There are differences post 2008
g
i am using the old way using rownum and maxrows, its not using fetch and next
i can safely say abouve 2012
g
btween i already did, my question was i saw a tutorial, that i saw somewhere datatables code was done server side
don't want to rewrite, it was already somewhere so trying to use those bits and pieces to make it work '
p
That’s literally the SQL what more do you want?
g
that part is done, i showed in my screenshot, honeslty i was looking for already created code because i do not want to rewrite same thing again so was looking it was used somewhere so i can reuse or a tutorial where i can get
p
Oh, no. But I am available for consultation if your company requires
g
đŸ™‚
thanks @paul the reason i am asking is because my brain is all fried up and has no urge of coding anymore so looking for a build in feature
m
as datatables doesn't directly talk to sql, on your current code, are you using old or new style? (afaik, both are usable with current version ) new style is declared by DataTable(): we send back {data:, draw:, recordsTotal:, recordsFiltered:} start, length are what you will receive in your request from datatables to work with paging recordsTotal will hold your maxrownum recordsFiltered will hold the count sent back for this page function I use for setting up sql server paging, ymmv
Copy code
public string function limit( required struct inArgs ) {
		local.limit = "";
		local.maxLength = 100; // we don't want to exceed 100 (when using paging)

		// for paging, must have a start and length. length = -1 is all records
		if ( arguments.inArgs.KeyExists("start") && arguments.inArgs.KeyExists("length") && arguments.inArgs.length != -1  ) {
			local.fetchSize = arguments.inArgs.length;

			if ( !local.fetchSize || local.fetchSize gt local.maxLength ) {
				local.fetchsize = 10;
			}

			local.limit = " offset #val( arguments.inArgs.start )# rows fetch next #val( local.fetchSize )# rows only ";
		}

		return local.limit;
	}
old style is declared by dataTable(): we send back {sEcho:, iTotalRecords:, iTotalDisplayRecords:, aaData: } iDisplayStart, iDisplayLength are what you will receive in your request from datatables to work with paging iTotalRecords will hold your maxrownum iTotalDisplayRecords will hold the count sent back for this page