Horizontal scrolling and javascript array
Horizontal scrolling and javascript array
Fabricio_ndas
Posts: 10Questions: 0Answers: 0
Hello,
I was looking for an example of Horizontal scrolling and javascript array together in the same table, Because I was trying use both but it didn't worked fine.
Thanks!
I was looking for an example of Horizontal scrolling and javascript array together in the same table, Because I was trying use both but it didn't worked fine.
Thanks!
This discussion has been closed.
Replies
http://datatables.net/release-datatables/examples/data_sources/js_array.html
http://datatables.net/release-datatables/examples/basic_init/scroll_xy.html
What have you got so far?
Allan
First: I'm using the same table that i was using with 1.6 version, I've updated it to 1.8, now when I add a new line dinamically using server processing it doesn't update automatically, it just update if i refresh page or change the sort type.
Table code:
[code]
oTable = $('#grid').dataTable({
"oLanguage": { "sUrl": "media/language/pt-br2.txt" },
"sScrollY": 200,
"sScrollX": "100%",
"sScrollXInner": "110%",
"bJQueryUI": false,
"sPaginationType": "full_numbers",
"bProcessing": false,
"bServerSide": true,
"sAjaxSource": "server_processing_agencias.php",
"bAutoWidth": false,
"bLengthChange": true,
"sDom": '<"top"f<"clear">ip<"clear">> <"bottom"t>',
"aoColumns": [
// null,
{ "sTitle": "ID BANCO" , "sWidth": "10%", "bSortable": true, "bVisible": false },
{ "sTitle": "BANCO" , "sWidth": "25%", "bSortable": true, "bVisible": true },
{ "sTitle": "ID" , "sWidth": "5%", "bSortable": false, "bVisible": false },
{ "sTitle": "AGÊNCIA" , "sWidth": "25%", "bSortable": true, "bVisible": true },
{ "sTitle": "NÚMERO" , "sWidth": "5%", "bSortable": false, "bVisible": false },
{ "sTitle": "DIGITO" , "sWidth": "5%", "bSortable": false, "bVisible": false },
{ "sTitle": "LOCAL" , "sWidth": "30%", "bSortable": true, "bVisible": true }
],
"aaSorting": [[ 1, 'asc' ]]
});
[/code]
Save function to add new line:
[code]
$("#save").click(function() {
var str_data = "&table="+encodeURI($("#table").val())+
"&id="+encodeURI($("#id").val())+
"&id_banco="+encodeURI($("#id_banco").val())+
"&numero="+encodeURI($("#numero").val())+
"&digito="+encodeURI($("#digito").val())+
"&nome="+encodeURI($("#nome").val())+
"&local="+encodeURI($("#local").val());
var r = 0;
$.ajax({
type: "POST",
url: "save.php",
dataType: 'json',
data: str_data,
success: function(msg) {
oTable.fnDraw();
}
});
$("#edicao").hide();
$("#listagem").show();
[/code]
The second problem is happening with another table then I'll tell later when i get this problem solved
Thanks for helping and sorry for bother you.
Allan
I didn't get any errors...
Server side processing code:
[code]
<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
/* Array of database columns which should be read and sent back to DataTables */
$aColumns = array( 'idbanco','banco', 'id', 'agencia', 'numero', 'digito', 'local' );
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "id";
/* Database connection information */
/*
$gaSql['user'] = "myuser";
$gaSql['password'] = "mypassword";
$gaSql['db'] = "mydb";
$gaSql['server'] = "myserver";
*/
include("./conn.php");
/* REMOVE THIS LINE (it just includes my SQL connection user/pass) */
//include( $_SERVER['DOCUMENT_ROOT']."/datatables/mysql.php" );
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP server-side, there is
* no need to edit below this line
*/
/*
* MySQL connection
*/
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );
mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );
/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] );
}
/*
* Ordering
*/
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i
Allan
SyntaxError: JSON.parse: expected property name or '}'
And no, the alert doesn't shows up, it just happens when i'm using 1.8 version, if i put 1.6 it runs good
I'm sorry for my fault, I'm new with javascript and php...
Do you have any idea about what is happening?
Thanks for help, and sorry for bother you
I didn't solved the problem yet. Can you help me please?
Allan
I did as you told me to do and i got the following error message:
Parse error on line 1:
<?php/**************
^
Expecting '{', '['
The problem is that the alert before oTable.fnDraw(); doesn't shows up but it still saves, however, it doesn't update the table.
Thanks,
Fabricio