Quantcast
Channel: DataTables 1.9 — DataTables forums
Viewing all 1816 articles
Browse latest View live

bsavestate for more than two tables

$
0
0
First of All I really adore jquery datatables ,it's greaat :)

My problem is :
I've have 6 datatables in my page . and I use
"bStateSave": true
for all of them .
But nothing is saved . I reviewed my cache information .I just found 2 datatables in my cache only .
I've removed bsavestate from all the datatables then I set it one by one and test ,I found out that the state is saved for max two datatables only.
any help with this issue ?!

N.B, size range of each datatable is 1600-1800 KB .. I don't know is this browser cache size issue or is it an issue with datatables

server side use, nothing append on filter/search/order/next-prev, etc...

$
0
0
Hi,

I have a problem on server side use. The data are well loaded on content's display, but after, when i'm using input filters, search, etc... It's like ther is no server side call again. On firebug, I can't see XHR, is just call @ load only, nothing more on any action like next / prev or search.

I certainly have a mistake in the jquery call, but can't find where.

This is my code (warning php inside too):

var oTable = $('.dynamicTable').dataTable( { 
		    	"bProcessing": true,
		    	"bServerSide": true,
		    	"sAjaxSource": "stdout_json.php?r=<?php echo($table_name); ?>",
				"sPaginationType": "full_numbers",
				"bJQueryUI": false,
				"bAutoWidth": false,
				"bLengthChange": false,
				"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
		        "oLanguage": {
		            "sSearch": "Search all columns:",
		            "sLengthMenu": "_MENU_ records"
		        },
		        "bSortClasses": false,
			    "sDom": "<'row-fluid'<'span6'Tl><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
			    <?php echo $_SESSION["aoColumnDefs"]."\r\n"; ?>
		    	"bPaginate": true,
		    	"sPaginationType": "full_numbers",
		    	"iDisplayLength": 10,
		    	"bLengthChange": true,
		    	"bInfo": true,
		    	"bStateSave": true,
				"oTableTools": {
					"sSwfPath": "swf/copy_csv_xls_pdf.swf",
					"sRowSelect": "single",
					"aButtons": [
						{
		                    "sExtends": "select",
		                    "sButtonText": "Edit selected",
		                    "bSelectedOnly": "true",
		                    "mColumns": [0]
				        },
				        {
		                    "sExtends": "text",
		                    "sButtonText": \'<a data-target="#creProduct" data-toggle="modal">Create</a>\',
		                    "sToolTip": "Create a new product",
				        },
				        {
		                    "sExtends": "text",
		                    "sButtonText": \'<a data-target="#delProduct" data-toggle="modal">Delete</a>\',
		                    "sToolTip": "Delete product",
				        },
						{
							"sExtends":    "collection",
							"sButtonText": 'Export <span class="caret" />',
							"aButtons":    [ 
								"print",
								{
				                    "sExtends": "csv",
				                    "sButtonText": "CSV all columns",
				                    "sToolTip": "Save displayed table and all columns as CSV",
				                    "bShowAll": true,
				                    "mColumns": "all"
				                },
								{
				                    "sExtends": "csv",
				                    "sButtonText": "CSV visible columns",
				                    "sToolTip": "Save displayed table and visible columns as CSV",
				                    "mColumns": "visible"
				                },
				                {
				                    "sExtends": "pdf",
				                    "sButtonText": "PDF All columns",
				                    "mColumns": "all", 
				                    "sPdfOrientation": "landscape",
				                    "sPdfMessage": "<?php echo date('l jS \of F Y h:i:s A'); ?>"
				                },
								{
				                    "sExtends": "pdf",
				                    "sButtonText": "PDF Visible columns",
				                    "mColumns": "visible",
				                    "sPdfOrientation": "landscape",
				                    "sPdfMessage": "<?php echo date('l jS \of F Y h:i:s A'); ?>"
				                }
				            ]
						}
					]
				},
				"fnInitComplete": function() {
					var oSettings = $('.dynamicTable').dataTable().fnSettings();
					for ( var i=0 ; i<oSettings.aoPreSearchCols.length ; i++ ){
						if(oSettings.aoPreSearchCols[i].sSearch.length>0){
							$(".dynamicTable tfoot input")[i].value = oSettings.aoPreSearchCols[i].sSearch;
							$(".dynamicTable tfoot input")[i].className = "";
						}
					}
				},
				"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
					var id = aData[0];
		         	$(nRow).attr("id",id);
		         	return nRow;
		        },
		    	"fnDrawCallback": function () {
					/* Apply the jEditable handlers to the table */
		    			/*    	... removed dur to loooong message .....*/
				}
			});
			
					    
		    $(".dynamicTable tfoot th input").keyup( function () {
		        /* Filter 	on the column (the index) of this element */
		        oTable.fnFilter( this.value, $("tfoot input").index(this) );
		    } );


		    $(".dynamicTable tfoot th input").each( function (i) {
		        asInitVals[i] = this.value;
		    } );
		     
		    $(".dynamicTable tfoot th input").focus( function () {
		        if ( this.className == "search_init" )
		        {
		            this.className = "";
		            this.value = "";
		        }
		    } );
		     
		    $(".dynamicTable tfoot th input").blur( function (i) {
		        if ( this.value == "" )
		        {
		            this.className = "search_init";
		            this.value = asInitVals[$("tfoot input").index(this)];
		        }
		    } );
		    
		    $('.dynamicTable td').live('click',function(){
			    var aPos = pTable.fnGetPosition(this);
			    var aData = pTable.fnGetData(aPos[0]);
			    alert(aData);
			});

		    $.extend( $.fn.dataTableExt.oStdClasses, {
			    "sWrapper": "dataTables_wrapper form-inline"
			} );

Jquery Datatable very slow on IE10,but on Ie8 or Chrome very fast.

$
0
0
Hi,i have some problems using datatables on IE10, heavy CPU load 100%,time delay 13s,but on ie8 very fast,only 1s.
Can you help me? Thanks .

Not able to load ajax json data into DataTables

$
0
0
I am new to DataTables and not quite an expert in javascript/jquery either.

My table is populated with the original php/html file and it works fine with DataTables (DT for short). So, we are not talking here about initialization of DT, or so I believe.

Now,once the table is visible to the user I need to give him/her the possibility to apply filters to the table. Note that the filter parameters are NOT within the table data, so it is not the case of using the sorting/filtering tools from DT. The filtering with ajax/php was working fine prior to the use of DT, but after implementing DT I do not manage to repopulate it with the new data coming from the Ajax call.
I did manage to empty the table using fnClearTable(), so all I get now once I apply any filter is an empty table.
Here is myTable as from the original php file, starting withe the filter section:


<form id = "filter">
<input class="hook1" type="checkbox" value="115" name="hook[0]"> item1 <br >
<input class="hook1" type="checkbox" value="116" name="hook[1]"> item2 <br >
<input class="hook1" type="checkbox" value="107" name="hook[2]"> item3
</form> 

			<table id="myTable" class="display">
<thead> 
<tr> 
    <th>data1</th>
    <th>data2</th>
    <th>data3</th> 
    <th>data4</th> 
    <th>data5</th>
    <th>Compare</th>
</tr> 
</thead>
<tbody>
<?php
$sql = mysql_query ("SELECT * FROM vprice_range ORDER BY price");
    
while($r= mysql_fetch_assoc($sql)){
?>
	<tr>
		
		<td><?php echo $r["data1"] ; ?></td>
		<td><?php echo $r["data2"] ; ?></td>
                <td><?php echo $r["data3"] ; ?></td>
                <td><?php echo $r["data4"] ; ?></td>
                <td><?php echo $r["data5"] ; ?></td>
        <td>Select: <input type="checkbox" name="vid[]" value= "<?php echo $r["version_id"] ;?>" onclick="chkChecks('vid[]')" />
                </td>
	</tr>
<?php
}
unset ($sql);
unset ($r);
?>
</tbody>
</table>

Here is my JQuery/Ajax so far ( placed at the <head> section of the above php file.

 
$(document).ready(function(){	
$("#filter").change(function()
{
      var str = $("#filter").serialize();
      var oTable = $('#myTable').dataTable();
   // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
        oTable.fnClearTable();
     $.ajax({
            url: "filter_prange.php",
            type: "POST",
	    dataType:"json",
           data: str,
           success: function fnClickAddRow(data) {
  $('#myTable tbody').dataTable().fnAddData(data);
     }
  });    
  });
  });

This is the filter_prange.php file.
$connect = mysql_connect("localhost", "root", "root");
mysql_select_db("mydb");
$trimids = array();
$trimids = $_REQUEST['hook'];
$qty = count($trimids);
$trimids = implode(",", $trimids);


    if($qty == 0){
    $sql = mysql_query ("SELECT * FROM vprice_range ORDER BY price");
    }
    else {
    mysql_query("CREATE OR REPLACE VIEW vrange AS (
SELECT ................)
    $sql = mysql_query ("SELECT * FROM vrange ORDER BY price");
    }
while($r= mysql_fetch_assoc($sql)){
	echo '<tr>';
		echo '<td>' . $r["data1"] . '</td>' ;
		echo '<td>' . $r["data2"] . '</td>' ;
                echo '<td>' . $r["data3"] . '</td>' ;
                echo '<td>' . $r["data4"] . '</td>' ;
                echo '<td>' . $r["data5"] . '</td>' ;
                echo '<td>' . 'Select:' . '<input type="checkbox" name="vid[]" value=' . $r["version_id"]  . 'onclick="chkChecks("vid[]")" ' . '/>' . '</td>' ;
	echo '</tr>' ;
}
unset ($sql);
unset ($row);
mysql_query("DROP VIEW vrange");

And this is an example of the JSON I am getting back from the filter_prange.php file ( as verified by Firebug).
<tr><td>data1</td><td>data2</td><td>data3</td><td>data4</td><td>data5</td><td>Select:<input type="checkbox" name="vid[]" value=259onclick="chkChecks("vid[]")" /></td></tr><tr><td>data1</td><td>data2</td><td>data3</td><td>data4</td><td>data5</td><td>Select:<input type="checkbox" name="vid[]" value=9onclick="chkChecks("vid[]")" /></td></tr> etc....

As you can see in my jQuery I am trying to used fnAddData(), but it is not clear to me if that's the right plug in nor which parameters, if any, I should provide.
Thanks for any assistance.

Oracle Server side - common error ?

$
0
0
It seens to be a lot of posts around this but i wasn't able to find a proper solution for this.

Using the default script provided, when i try to execute the php_oracle.php ( content of the file is : http://www.datatables.net/development/server-side/php_oracle )

I receive de rerror:


Warning: oci_bind_by_name() [function.oci-bind-by-name]: ORA-01036: illegal variable name/number in D:\Program Files\xampp\htdocs\cmportal\tests\datatable\scripts\php_oracle.php on line 233

Warning: oci_bind_by_name() [function.oci-bind-by-name]: ORA-01036: illegal variable name/number in D:\Program Files\xampp\htdocs\cmportal\tests\datatable\scripts\php_oracle.php on line 234

Warning: oci_execute() [function.oci-execute]: ORA-30485: missing ORDER BY expression in the window specification in D:\Program Files\xampp\htdocs\cmportal\tests\datatable\scripts\php_oracle.php on line 260

Warning: oci_fetch_array() [function.oci-fetch-array]: ORA-24374: define not done before fetch or execute and fetch in D:\Program Files\xampp\htdocs\cmportal\tests\datatable\scripts\php_oracle.php on line 262

Warning: oci_execute() [function.oci-execute]: ORA-30485: missing ORDER BY expression in the window specification in D:\Program Files\xampp\htdocs\cmportal\tests\datatable\scripts\php_oracle.php on line 281

Warning: oci_fetch_array() [function.oci-fetch-array]: ORA-24374: define not done before fetch or execute and fetch in D:\Program Files\xampp\htdocs\cmportal\tests\datatable\scripts\php_oracle.php on line 284
{"sEcho":0,"iTotalRecords":"163","iTotalDisplayRecords":0,"aaData":[]}


Im new to php and datatables, so it would be great to have a practical example =)

How do I set the row height in dataTables

$
0
0
Actually, I am scrolling through the table but behaing in a wierd manner as the row are having different heights.
Can you please help me out.

Requested unknown parameter '0' from the data source

$
0
0
Hi all,

I try to build an application with the help of this great plug-in datatables.

But actually I have a problem which I can't solve.

I used the debugger and the code is "ogaves".

I hope anybody can help me.

How to prevent memory leak when using Jquery - datatables (ie7)?

$
0
0
I am using datatables in my Javascript application but when rendering the DOM, memory of IE grows up like anything. Memory doesn't come down even after clearing the datatatables element from DOM.

I have multiple tabs and i remove the LI part of the DOM to remove the tab which host the datatable.

If I dont render the DOM via datatables, the utilized memory is very less..

var functionLoad=(function (datasource){
        var oTable = $("#" + elementId).dataTable({})
});

Can someone let me know the best way to prevent memory leaks when using IE7?

Is there a way to remove reference of table element?

incorrect filter total records number when filtering via server-side.

$
0
0
hi allen

i am using the individual column filter(input) feature via Server-side. i find the filtered info is "filtering from _MAX_ records" and the _MAX_ variable might be equals to "iTotalRecords" i set in Server-side.

then i got the filtered info after filtering DataTable like below:
Showing 1 to 25 of 74 entries (filtered from 25 total entries)

i think the total entries of filtered might be incorrect. in this case, "iTotalRecords" is 25 and "iTotalDisplayRecords" is 74. but there is 100 data before filtered. maybe i need change the jquery.dataTables.js or find another way to solve it?

here comes my discovering in jquery.dataTables.js(DataTables-1.9.4):
line-9329: "sInfoFiltered": "(filtered from _MAX_ total entries)",
line-2571: replace(/_MAX_/g, sMax);
line-2558: sMax = oSettings.fnFormatNumber( iMax );
line-2557: iMax = oSettings.fnRecordsTotal(),
line-11344~11351:
"fnRecordsTotal": function ()
{
if ( this.oFeatures.bServerSide ) {
return parseInt(this._iRecordsTotal, 10);
} else {
return this.aiDisplayMaster.length;
}
},
line-2025: oSettings._iRecordsTotal = parseInt(json.iTotalRecords, 10);

How do in js code configuration header colspan

$
0
0
like html:
<tbale>
      <thead>
             <tr><th colspan='2'>col_1</th><tr>
             <tr><th>col_2</th><th>col_3</th></tr>
      </thead>
      <tbody></tbody>
</table>
how to transform in js?

My dataTables with jQuery UI theme are not same as example

Did not get Resized

$
0
0
Hi,
i have a problem in table size.When i resize the browser the table displayed in standard size.if i reload page it table fit to the page.
How to i resolve it? help me

my Initial code like this


oTable = $('#NatureDisplay_table').dataTable( {
"bJQueryUI": true,
"bDestroy":true,
"bRetrieve": false ,
"oLanguage": {
"sSearch": "Search all columns:"
},
"bProcessing": true,
"sScrollY": x,
"bScrollCollapse": true,
"sPaginationType": "full_numbers"
} );

table header also fixed..

Drill-down data

$
0
0
I have a few questions regarding the drill down.

I have a drill down but would like to make an ajax call to get the data. Is there an example of how to make the ajax call for this? I have a ajax call for the data table already but would like additional data for the drill down. Currently the drill down is using the data from the original ajax call.

I would like the drill down data to be editable fields that when the blur function kicks off for each field it posts back to the server. Is it possible to do this? I have blur functions for each field but the function doesn't seem to fire when I move off the field.

newbee using dattable

$
0
0
I am newbee, trying to use tabale with ajasource. Its not working, please advide whats wrong
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://datatables.net/download/build/jquery.dataTables.js"></script>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/springrest/css/demo_page.css" />
<link rel="stylesheet" type="text/css" href="http://localhost:8080/springrest/css/demo_table.css" />
<script type="text/javascript"> 
$(document).ready(function() {
    $('#displayData').dataTable( {
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "http://localhost:8080/springrest/rest/service/cities.json"
    } );
} );
</script>	
</head>




<body>
	
<table class="display" id="displayData"> 
    <thead>
        <tr>
            <th align="left">Name</th>
            <th align="left">Telephone Code</th>
            <th align="left">Population</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td colspan="3" class="dataTables_empty">Loading data from server</td> 
        </tr>
    </tbody>
</table>	
	
	
</body>
</html>

this is the error in chrow console

XMLHttpRequest cannot load http://localhost:8080/springrest/rest/service/cities.json?sEcho=4&iColumns=…gCols=1&bSortable_0=true&bSortable_1=true&bSortable_2=true&_=1364326752076. Origin null is not allowed by Access-Control-Allow-Origin. 

please advice me how to fix this.

How to cancel a sorted colum?

$
0
0
Hi, guys!

I'm new to use DataTables. Here is my question.

As i'm using JQuery UI Dialog to popup the datatable to show the data. But i triggered the sort action and closed the dialog, when i opened the dialog again, the DataTables was still being the sorted state! Is there any possible to cancel an already sorted column?

Here is my init code, so i can init datatable without default sort action. But i don't know how to cancel the already sorted state.

$("#table").dataTable({
    "aaSorting" : []
})

Thanks!

fixed row height in the table

$
0
0
Hi,
I wanted a fixed row height. However, each td element contains data which is overflowing, comes to the next line & consequently increases the height of the row. Is there a way to fix the height of the row.
I also tried to insert a div element inside the function & use the foll css:-

table#example tbody td div{
width:160px;
height:28px;
overflow:hidden;
word-wrap:break-word;
}

It did fixed the height & width of the div element inside the td element, but caused a break in the nTd variable & hence also the iRow variable remained undefined. Any workaround would be appreciated.

Thanks for looking.

Firefox Dialog Hidden

$
0
0
DataTables 1.9.4 and TableTools 2.1.5 SUSE Linux 12.2 and Firefox 17.0

The Save as PDF, CSV etc all work except that the dialog is displayed behind Firefox and so is not visible.
Is this a FireFox issue or a DataTables/TableTools problem?

Thanks

Mike

Advice needed how to use "live" checkboxes with datatables ($.fn.dataTableExt.afnFiltering, fnDraw?)

$
0
0
Hi,

I'm discovering datatables and novice to javascript and DOM.
Currently i face problem where I need to modify datatable onthefly and how it renders (draws) page.
I have couple of checkboxes which when selected should enable/disable columns and couple of scrolldowns that should use search.
Sample is shown in: http://live.datatables.net/esufaw/edit#javascript,html

First I thought that I should use $.fn.dataTableExt.afnFiltering - but with that I got only partly solution and not the full one.

Can anybody help/point me in the right direction?
(I found that http://live.datatables.net/oyinin/3/edit#preview is somewhat useful for me?)

What and how would be best.

Also - multiple column/row filter is needed - for this I did not find any solution :S
Br,
KT.

Proper syntax for calling fields in mRender function or mData

$
0
0
Hello and thank you for this excellent jQuery tool. I am using it to display SQL database information information in an ASP classic application. I use "sAjaxSource": "/json_data.asp" to get the data, which is in the "aaData" array of objects format. { "aaData" : [ {"Field1"."Value1","Field2"."Value2"},{"Field2"."Value1","Field2"."Value2"} ] }.

Using this data source and using {"mData":"FIRST_NAME"} (etc.) in aoColumns to bind the specific data to the <th> columns, everything is working fine. Now the hard part for me, since I'm a beginner at JS and JQuery.

What is the correct syntax to use when calling other fields from the data into that column? Whether it's for an "if" statement or "return" within a function, or calling them directly without a function. For example, within aoColumns or aoColumnDefs:

a)
	{ "mRender" : function (data, type, full) { return {"mData": "FIRST_NAME"} + ' ' + {"mData": "LAST_NAME"}; } },   
where FIRST_NAME and LAST_NAME are the field names in the data source
or
b)
	{ "mRender" : function (data) { return data.aaData[3] + ' ' + data.aaData[4]; } },     
where aaData[3] and aaData[4] are the positions of the data in the aaData array, not necessarily the table being displayed.
or
c)
	{ "mData" : "FIRST_NAME" + ' ' + "LAST_NAME"}    
would have been the simplest.

I'm unclear on the differences between aoColumns and aoColumnDefs (I looked up the reference info on aoColumnDefs but couldn't find a list of methods etc like I could for other things), and also when to use mData vs mRender (or both) and examples of each.

Most importantly I need to know how to reference one or more fields from the data source with the proper syntax.

In example a) above I am given the typical "Requested unknown parameter 0 from the data source for row 0" and in example b) I'm told that "data is null" (I've seen examples of using "data" as an object name or variable referring to the current column or record's data). For c) I get the unknown parameter FIRST_NAME LAST_NAME or if I wrap those in {} I get unknown token errors.

For those suggesting I should combine / reference the other data fields when querying my data source or constructing the array, note that neither of those options are available to me. I need to combine two fields in the display of the column, or in another column I need to use a value from one field in an <a href> while displaying the value from another field.

Thanks very much for this help!

Can not populate JQuery DataTable with my json data

$
0
0
I'm stuck completely while accessing the data from asp.net web service to .aspx page. I used the Newtonsoft.Json.JsonConvert.SerializeObject(qry, Formatting.Indented) for creating a JSON string.

This library provides a genuine and valid JSON string like following:
[ { "DepartmentId": 0, "Department": "CIVIL ENGG.", "DepartmentShortName": "CIVIL" },
{ "DepartmentId": 10, "Department": "COMPUTER SCIENCE ENGINEERING", "DepartmentShortName": "C.S.E." },
{ "DepartmentId": 21, "Department": "ELECTRICAL & ELECTRONICS ENGG.", "DepartmentShortName": "E.N." },
{ "DepartmentId": 31, "Department": "ELECTRONICS & COMMUNICATION ENGG.", "DepartmentShortName": "E.C.E" } ]

The code snippet to populate the datatable is:
$(document).ready(function() {
$.ajax({
type: "POST",
url: webServiceURL,
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(json) {
$('#grid').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": webServiceURL,
"fnServerData": fnDataTablesPipeline
});
}
});
});
for complete set of code, I referred the http://www.datatables.net/examples/server_side/pipeline.html link and indeed tried many other options but no luck.

I suspect that it can be occurred because of 'sEcho', 'iDisplayStart' and 'iDisplayLength' are missing from json but when I used my json string within aspx page and passed to 'aaData', it works fine.

I'm lost and not finding any solution since last three days. I believe some help will come out here..

Thanks in advance
Viewing all 1816 articles
Browse latest View live