Code Monkey home page Code Monkey logo

Comments (5)

irvine48 avatar irvine48 commented on May 27, 2024 1

Hi, here attached with my setup for ajax without server side processing for configuration.

<script type="text/javascript" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script> <script type="text/javascript" src="https://cdn.datatables.net/fixedcolumns/3.2.4/js/dataTables.fixedColumns.min.js"></script>

$(document).ready(function() {
$('#table_merchant_list').DataTable( {
"order": [[ 0, "asc" ]],
"pageLength": 5,
"scrollX": true,
"fixedColumns": {
leftColumns: 2
},
// "bProcessing": true,
// "bServerSide": true,
"sAjaxSource": "test/jxindex",
"columns": [
{ data: "id" },
{ data: "name" },
{ data: "city" },
{ data: "tel" },
{ data: "email" },
{ data: "contact" },
{ data: "created_date" },
{ data: "status" },
{ sortable: false, "render": function ( data, type, full, meta ) {
var rowID = full["id"];
return '<a href=/contacts/'+encodeURI(rowID)+' class="btn btn-info">Edit';
}
}
]
} );
} );

function jxIndex($request, $response)
{		
	$config = array(
			'host'     => 'localhost',
			'port'     => '3306',
			'username' => 'xxx',
			'password' => 'xxx',
			'database' => 'xxx' );

	$dt = new Datatables( new MySQL($config) );

	$dt->query("
	Select 
		id, name, city, tel, email, contact, created_date, status
	FROM 
		contact
	");

	echo $dt->generate();
	exit();
}

what i see here is, retrieve whole chunk of data instead of process the parameters from ajax to retrieve require data. So maybe can include in next update.

from datatables.

irvine48 avatar irvine48 commented on May 27, 2024

by turning off this two make it processing by datatables without server side support, which way is better? server side produce require data or give a large chunk of data and let datatables process it?

$('#table_merchant_list').DataTable( {
// "bProcessing": true,
// "bServerSide": true,
...
});

from datatables.

n1crack avatar n1crack commented on May 27, 2024

Can you show me your setup? Which version of datatables do you use?
Sorting and pagination etc. must work as expected.

from datatables.

TiTnOuK avatar TiTnOuK commented on May 27, 2024

@irvine48 Server side is better when you have to display a lot of results from an expensive query (mysql or another). You will be able to recover only the elements to be displayed according to the pagination parameters (start and length) sent during the server request.
On the other hand if you have little data to display, the client side does the job very well.

For your problem, I think you use incompatible datatables lib version (< 1.10). Try to use last stable version from offical website https://datatables.net/download/

from datatables.

n1crack avatar n1crack commented on May 27, 2024

"bServerSide": true,

you should enable this. Otherwise whole data will be loaded.

your setup looks ok to me.

from datatables.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.