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

How to sort "numerically"

$
0
0
Hello,

I need sort column as "numeric".
I used this code
// passing options in costructor
"aoColumnDefs": [
   { "sType": "numeric", "aTarget": [0] },
   { "sType": "numeric", "aTarget": [0] },
   { "sType": "numeric", "aTarget": [0] },
   { "sType": "numeric", "aTarget": [0] }
]

Columns are sorted as "string"

Any help?

datatables stops working if checked checkboxes with names with brackets ("[" "]") ajasub

$
0
0
Hi
There is very strange behaviour of datatables. So I can't make jsfiddle or show on the website so I will try to describe whats happen with debug code.
So, I load page, datatable works fine. It pulls up data from the server with the filter form. Here is html of the form http://live.datatables.net/ezacul/edit#javascript,html. But when I check some of `<input name="bulk[]"` checkboxes, datatable not work to the end, so word `Processing` never disappear until next page loaded or uncheck all `bulk[]` checkboxes. I have made debug here is code: ajasub

Please help.

Strange behavior between datatables and php

$
0
0
Hi,

I have this problem: have 2 files ini.php and search.php

the file ini.php contains

<select name="Combobox1" onchange= "MostrarResultados()" id="Combobox1" style="width:120px"></select>

function MostrarResultados(){
cate= $("#Combobox1").val();

$.ajax({
type: 'POST',
url: 'search.php',
data:{datos:cate},
success: function(data) {
alert("Data Loaded: " + data); // to see if i get back data form search.php
var oTable = $("#dataTable").dataTable();
oTable.fnClearTable();
oTable.fnDestroy();
$('#dataTable').dataTable( {,
"bServerSide": true,
"sAjaxSource": "../search.php",
"oLanguage": {
"sLengthMenu": "Mostrar _MENU_ Registros por página",
"sZeroRecords": "No se encontró nada",
"sInfo": "Mostrando del _START_ al _END_ de _TOTAL_ Registros",
"sInfoEmpty": "Mostrando del 0 al 0 de 0 Registros",
"sInfoFiltered": "(Filtrado de un total de _MAX_ Registros)"
},
"aLengthMenu": [[5, 10, 15, -1], [5, 10, 15, "Todo"]]
});
$("#dataTable_previous").html("Anterior");
$("#dataTable_next").html("Siguiente");
$("#dataTable_filter label").contents().first().remove();
$("#dataTable_filter label input").attr('placeholder', 'Buscar');

}
});
}

On the other hand my search.php contains

<?php
include ('Conex.php');

$datareceived=$_POST['datos'];

$sql = mysqli_query($conex,"SELECT a.description as Description, a.idcategoria as idcategoria FROM categoria a WHERE Active = 'S' AND a.idcategoria = '$datareceived' ");

$aColumns = array( 'Description', 'idcategoria');

$output = array(
"aaData" => array()
);

while ($registro = mysqli_fetch_array($sql))
{
$row = array();
for ( $i=0 ; $i<count($aColumns) ; $i++ )
{
switch ( $aColumns[$i]){

case "Description":
$row[] = $registro[ $aColumns[$i] ] ;
break;
default:
$row[] = $registro[ $aColumns[$i] ];
}
}
$output['aaData'][] = $row;
}
mysqli_free_result($sql);

echo json_encode( $output );

?>

THE PROBLEM is on the sql sintax and datatables, if i do a.idcategoria = '$datareceived' it doesn't show data on the datatable, although it gives back the data because i can see it in an alert on ini.php.
If i do a.idcategoria = 22 it works perfect, fills the datatable

I compare the output in the two cases with DiffMerge and it's the same in both.

Can anyone please help me, i don´t have any idea of what's happening here and i'm new with this pluging

Thanks

How can i add a button next to search box ?

$
0
0
Good day,

Could anyone please enlighten me how can i add a button next to Search box?

Thanks

How can i add few more filtering in data table?

$
0
0
good day,

Could anyone please share with me how can i add more filter criteria and improve the searchable result?

Thanks

Can't Select Table Rows for New Rows Only

$
0
0
Hi, I've seen some discussions on here regarding this but not exactly matching my situation that I could find.

I'm adding new data to the table by using fnAddData() dynamically. The the new row of data is added correctly to the table, however I'm not able to select the row by clicking on it. All table rows that were not dynamically added are still selectable.

I have the following code that toggles the table rows if they are selected or not. Keep in mind I'm allowing for multiple rows to be selected.

Any suggestions on how to resolve this would be greatly appreciated as I can't seem to locate the issue. I've even tried placing an alert() within the click event below and the alert() is never executed when trying to click (select) on the dynamically added table rows.

$('#example tr').click( function() {
$(this).toggleClass('row_selected');
} );

Here is the code used for toggling selected table rows and the dynamic code that adds new data to the table.
https://gist.github.com/thewarden/cdcbaee26cc244fe3049


Here is my DataTables debug.
http://debug.datatables.net/eyotid

Multiple Headers: Filter enabled with Sort Disabled

$
0
0
Hi, thanks for this most excellent library.

Problem:
have a datatable with multiple headers that span multiple columns (4 cols) and am unable to get filter working on data columns.

I can disable sorting with:
bSort: false

but filter functionality appears to be broken, presumably due to the headers spanning multiple columns.

Can we have multiple header rows with filterable data?

Thanks for clues.

Searching a text in multiple columns and filter datatable based on the result

$
0
0
I would like to get help about datatable’s multi-column searching for a given input text. I know that single column and global filtering option is available in the datatable fnFilter() but I haven’t found anything for multi-column searching scenario. Please note that this is not server side processing.

Let me give an example, I have a search filter textbox (txtName) which filters “name” but I would like to filter based on the value in “Primary Name”, “Secondary Name” and “Other Name” column in datatable.

Search Text: “name”

Id	Primary Name	Secondary Name	Other Name	OtherColumn

1	Some name	NA
2	NA	        Some name	
3	NA	        NA
4	NA	        NA
5			                     Some name	

So the result should display the following result

Id	Primary Name	Secondary Name	Other Name	OtherColumn

1	Some name	NA
2	NA	        Some name	
5			                    Some name	

I tried the following code seeing example from forum (http://datatables.net/forums/discussion/1164/multi-column-filtering/p1#Form_Comment) but it didn't workout


$(document).ready(function () {

var oTable = $('#myGrid').dataTable({
                "bJQueryUI": true,
                "iDisplayLength": -1,
                "sScrollY": "320px",
        	"sScrollX": "100%",
        	"sScrollXInner": "110%",
                "bLengthChange": false,
                "aoColumns": [
                        { "sName": "c0" },
                        { "sName": "c1" },
                        { "sName": "c2" },
                        { "sName": "c3" },
                        { "sName": "c4" },
                        { "sName": "c5" },
                        { "sName": "c6" },
                        { "sName": "c7" },
                        { "sName": "c8" },
                        { "sName": "c9" }                        
                        ]
            });

$('txtName').keyup(function () { fnFilterMultiple(oTable); 

});
function fnFilterMultiple(oTable) {
            var inst = '';
            inst = $('#txtName').val();
            //var defaultFilters = { "2": inst, "4": inst, "5": inst };
            var defaultFilters = { "c2": inst, "c4": inst, "c5": inst };
            oTable.fnMultiFilter(defaultFilters);
        }





_fnSetMultiFilterData = function (oSettings, fData) {
            for (var key in fData) {
                if (fData.hasOwnProperty(key)) {
                    //Loop through all the columns and configure the column w/ the matching name 
                    for (var i in oSettings.aoColumns) {
                        if (oSettings.aoColumns[i].sName == key) {
                            /* Single column filter */
                            oSettings.aoPreSearchCols[i].sSearch = fData[key];
                        }
                    }
                }
            }
            return oSettings;
        }

        this.fnMultiFilter = function (fData) {
            var oSettings = _fnSettingsFromNode(this[DataTable.ext.iApiIndex]);
            var oSettings = _fnSetMultiFilterData(oSettings, fData);
            //Loop through all elements in fData and configure them in the settings. 
            _fnFilterComplete(oSettings, oSettings.oPreviousSearch, 1);
        }

Can anyone please provide any sample code? Thanks in advance and your help is much appreciated.

-Miran

Highlighting rows first column not

$
0
0
Here's the page content I can highlight all but the first column???


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Testing DataTable</title>

<link rel="stylesheet" type="text/css" href="layout/css/jquery.dataTables_themeroller.css" />
<link rel="stylesheet" type="text/css" href="layout/css/style.css" />
<link rel="stylesheet" type="text/css" href="layout/css/jquery.dataTables.css" />
<link rel="stylesheet" type="text/css" href="layout/css/jquery-ui-1.10.3.custom.css"/>
<style>
.row_selected {
background-color: #099cc !important;
}
</style>

<script type="text/javascript" src="layout/js/jquery-2.0.3.js"></script>
<script type="text/javascript" src="layout/js/jquery-ui-1.10.3.custom.js"></script>
<script type="text/javascript" src="layout/js/jquery.dataTables.min.js"></script>
<script type="text/javascript">
var oTable;
$(document).ready(function() {

oTable = $("#fun_stuff_tbl").dataTable();

/* Add a click handler to the rows - this could be used as a callback */
$("#fun_stuff_tbl tbody tr").click( function( e ) {
if ( $(this).hasClass('row_selected') ) {
$(this).removeClass('row_selected');
}
else {
oTable.$('tr.row_selected').removeClass('row_selected');
$(this).addClass('row_selected');
}
});


});

</script>

</head>
<body>
<table id='fun_stuff_tbl'>
<thead>
<tr>
<td>Name</td>
<td>Address</td>
<td>City</td>
<td>Zip</td>
</tr>
</thead>
<tbody>
<tr>
<td>John Green</td>
<td>132 Green Ave</td>
<td>Greeville Texas</td>
<td>02334</td>
</tr>
<tr>
<td>John Green</td>
<td>132 Green Ave</td>
<td>Greeville Texas</td>
<td>02334</td>
</tr>
<tr>
<td>John Green</td>
<td>132 Green Ave</td>
<td>Greeville Texas</td>
<td>02334</td>
</tr>
<tr>
<td>John Green</td>
<td>132 Green Ave</td>
<td>Greeville Texas</td>
<td>02334</td>
</tr>
</tbody>
</table>
</body>
</html>

How to derive Data Tables values from Database?

$
0
0
Hi All,

I am new to data tables.

I am using jsp pages to view the data's derived from the database to view in the browser. In this I am using the <display:tag> for showing the data and pagination.

Eg.
<display:table name="dataList">

In this the dataList collects the data derived from the database. I want to use this in data tables.

Can some one explain how can i display the data in using this data tables.

Thanks in advance
Dinesh M K

Issue With Pagination

$
0
0
I have a datatable in which I am assigning the values by iterating a list which contains my table data. The last column (Actions) of my table contains 2 icons i.e Open & Delete for which the markup I have written is this :
<td> 
        <i class="icon-folder-open"></i>
</td>


I alert the row values when this icon is clicked. This works perfectly when I am on the first page of the table, as i move to page next page the click doesnt work at all. I tried to display all the records in a single page (i.e. by disabling pagination) and everything worked fine.

something is wrong with the pagination. It would be great if anyone can help me on this

I am using datatables 1.9.4 version

ColReorder and bSort set to false

$
0
0
It seems that setting bSort to false in the config prevents ColReorder from working (or initialising), but I can't see any reference to bSort in ColReorder. Is it possible to use ColReorder but prevent the columns from being sortable at the same time?

What determines row color in jquery datatable styles?

Basic usage of table - Table is created on the fly

$
0
0
I am using this plugin for the first time. I am developing an application using web2py framework of python. This application has a view(.html) file. I am creating a dynamic table in it by using python code blocks in between. I want this table to have sorting and paging capabilities. I have downloaded datatables plugin andplaced it in my application. The code which I have inclided in html file is given below:
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Login</title>
<link href="{{=URL('static','css/payments/style.css')}}" rel="stylesheet" />
<script type="text/javascript" language="javascript" src="{{=URL('static','css/payments/DataTables-1.9.4/media/js/jquery.js')}}"></script>
<script type="text/javascript" language="javascript" src="{{=URL('static','css/payments/DataTables-1.9.4/media/js/jquery.dataTables.js')}}"></script>
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
		$('#example').dataTable();
	} );
</script>
</head>

<body>
<div> 
<table id="example">
				<thead>
							<tr>
								<th>ID</th>
								<th>Method</th>
								<th>Date</th>																
								<th>Status</th>	
								<th>Account</th>
								<th>Name</th>
								<th>Amount1</th>																
								<th>Amount2</th>	
								<th>Type</th>	
							</tr>
				</thead>
						<tbody>	
							{{try:
							for obj in result['output']:
							}}
							<tr>
							<td>{{=obj['id']}}</td>
							<td>{{=obj['method']}}</td>
							<td>{{=obj['date']}}</td>
							<td>{{=obj['status']}}</td>
							<td>{{=obj['account']}}</td>
							<td>{{=obj['name']}}</td>
							<td>{{=obj['amount1']}}</td>
							<td>{{=obj['amount2']}}</td>
							<td>{{=obj['type']}}</td>
							</tr>
							{{else:}}
							<tr>
							<td colspan=9 align="center">No Data Available</td>
							</tr>
							{{pass}}
							{{except:
							pass}}							
							
						</tbody>
			  </table>

     </div>
</body>
</html>
Paging and sorting is not working on the table. Please correct me if I am doing anything wrong over here.

*- Content written between curly braces (ex- {{pass}}) is Python code which web2py evaluates at run time.

Infinite Scrolling adds infinite data to the table on table resize/redraw

$
0
0
Hi,

While writing this text and creating a test case on live.datatables.net I found the solution for my problem...
Anyhow I want to share my solution here to help others with similar problems.
This is also the solution for the unsolved problem mentioned in an old thread here:
http://datatables.net/forums/discussion/5733/infinite-scroll-and-window-resize/p1


In my project I've got a DataTable with "ScrollInfinite" enabled. My table has a flexible width so it changes its size on resizing the window. As infinite scrolling tables are "split" tables (separate head any body) the table columns get ripped apart on resizing. So I have to update the ColumnSize after that process.

See my fiddle here:
http://live.datatables.net/ocegiv/2/edit

The big problem is: fnAdjustColumnSizing() fires a call to get new data and adds new lines to the table. (just resize the window in my example: the table gets longer and longer...)
The simple solution is simply to add false to the function --> fnAdjustColumnSizing(false). Then the columns get rearranged without loading any new data.

Greetings,
sd

I need buil one system for insert into database

$
0
0
I need buil one system for insert into database and I am using datatables.
It is master/detail system.
I want send data from my datatable for my server in php.
I don't speak english very well but I need yours help.

Thank you.

Losing Pager styles after first click.

$
0
0
I have the jQuery plugin working pretty good on my table with pretty much the defaults.

var oTable = $("#tblResults").dataTable({
"sPaginationType": "full_numbers",
"bJQueryUI": true
});

The pager was originally kind of smushed up so I added this jQuery line right after the above line:
$("div.dataTables_paginate a").css("color", "#024785").css("font-weight", "bold").css("padding", "7px");

It looks great on the first load.
But the minute I click any pager a button or any sort button, the numbers in the pager lose the styles in the above line.
The First, Next, Previous and Last button links do not lose their styles.
The only difference I can see in the html source between First,Next and so on and the page number links is that the numbers are in a span tag within the div.
But they already in the span tag on first load and the styles show ok then.

Anyone know why the only page number links in the pager lose their styles?

How to totally disable ARIA

$
0
0
Is there a feature enablement / disablement to turn off ARIA completely in datatables? What would the JS look like? Thanks.

Isssue in PDF Export

$
0
0
Hi All,
First I thank for proving such a usefull tool.

I have DataTable with 5 Columns, and i am facing below issues

Issue #1: How to change the font-size while exporting to PDF.
Issue #2: I have an Address column in my DataTable, which has multiple line. While exporting to PDF, the Address column is not displaying as in DataTable Column. In DataTable, Address column displays as oneline after another. but in PDF its coming as single line.

Please help to resolve this. Thanks in Advance.

Cheers,
Balagangadharan.R

On user reordering or selecting drop down checkbox

$
0
0
I'm curious as to how I could go about performing some actions when the user reorders columns or selects a checkbox in the colvis dropdown to hide/show a column. Right now there doesn't appear to be any sort of functionality for this stuff...

Mainly I want to be able to perform some actions after the user has reordered a column and I want to have the information of the two column numbers being changed around so I can use that data elsewhere.

Same goes for the Colvis dropdown checkboxes. I want to know which specific boxes were checked/unchecked after the user performs the check/unchecking.

Would I need to dig into the js files for Colvis and ColReorder and pull that data out somehow?
Viewing all 1816 articles
Browse latest View live