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

incorrect result using fnGetNodes() after a value is searched in searchbox of jquerydataTables1.9.4

$
0
0
I am using jquery.dataTables.js(1.9.4).
I am using checkbox for select all and deselect all,but I wanted checked value of checkbox of all pages to be persisted so I used

$(xytable.fnGetNodes()).find("input[name='chklist']").length    //to get length of checkboxes
and

$(xytable.fnGetNodes()).find("input[name='chklist']:checked").length     // to find length of checked checkboxes

here xytable -->table id

but when I search a value in search box then the content changes say from 8 results their are only 2 result displayed(which is correct) but the length I get of all the checkboxes by fnGetNodes() remain 8 and not 2(which is incorrect) !!!!

javascript error if I enter 0 in input pagination in datatables-input pagination plugin used

$
0
0
1-error occurs if I enter 0 in input pagination in datatables Here I am getting aoData as undefined ,hence giving error during checking of aoData.nTR(line 14 here)..is any solution their to handle error if we enter 0 in pagination??

error at --if ( aoData.nTr === null ) ,here aoData is undefined if we enter 0 in pagination

This happens only when I search something and enter out of range +ve value in pagination box like 0 or 36 in condition their are only 3 pages(eg Page 1 of 3)

2-Also Entering 31 changes input(eg- Page 1 of 3,here 1 is input) to 3(if 31 is out of range) but if we enter -21 it does not change automatically to 0

plugin used for datatables is taken from http://datatables.net/plug-ins/pagination .Also jquery.dataTables.js version used is 1.9.4

if ( oSettings.aiDisplay.length !== 0 )
{
    var iStart = oSettings._iDisplayStart;
    var iEnd = oSettings._iDisplayEnd;

    if ( oSettings.oFeatures.bServerSide )
        {
            iStart = 0;
            iEnd = oSettings.aoData.length;
        }

    for ( var j=iStart ; j<iEnd ; j++ )
    {
      var aoData = oSettings.aoData[ oSettings.aiDisplay[j] ];
       if ( aoData.nTr === null )
            {
            _fnCreateTr( oSettings, oSettings.aiDisplay[j] );
            }

Filtering the records on checkbox selection in jsp

$
0
0
I am having some arraylist data displayed in center of a jsp page in divs.On Left hand side,i m having some checkboxes,I want the arraylist to be refreshed on selection of any one of the checkbox.
Please help me how to do that?

Default Sort on a Certain Letter?

$
0
0
I have a table of data shown by parsing xml. I would like it to sort by default on a certain letter. Is that possible?

For example by default, regardless of how the xml has the info, I'd like the table to start with all the U words at the top.

If there is some documentation on this, that would be great... or any ideas.

Thanks
Jason

requested unknown parameter

$
0
0
Yes, another one. I've read the other posts on this topic but I'm still confused. The page works sometimes, and other pages using the same code work okay, but this one page is throwing this error. The debug info is at "uhamot" and it show 12 columns which is wrong. The query only returns 6 columns. Why does it work the first time but not on subsequent tries? It's also throwing an "oColumn is undefined" error. Here's my code:
    $('#paraminputbtn').live('click', (function() {
        $('#option').val($('#selectedtablefield').val());
        $('#selectedtablefield').val()
        $('#waitimgdiv').show();
        $('#resultdiv').fadeOut();
        $('#exportdiv').hide('fast');
        var params = $('.inputfield').serialize();
        $('#exportdiv').html('<a href="/mfgweb/ExcelDataExport?' + params + '" ' + 'target="blank">Download to Excel</a>');
        var oTable = $('#resulttable').dataTable();
        oTable.fnDestroy();

        $('#resulttable').dataTable({
            'bFilter': true,
            'bSort': false,
            'bServerSide': true,
            'bAutoWidth': true,
            'sAjaxSource': '/mfgweb/DataExportAjax',
            'bPaginate': true,
            'sScrollY': '400px',
            'sScrollX': '100%',
            'sPaginationType': 'full_numbers',
            'bScrollCollapse': true,
            'bJQueryUI': true,
            'fnRowCallback': function(nRow, aData, iDisplayIndex, iDisplayIndexFull) {
                var rowID = 'row' + iDisplayIndexFull;
                $(nRow).attr('id', rowID);
                if ($('#selectedtablefield').val() == 'compprodrep' && aData[0] != '') {
                    $(nRow).addClass('activerecord');
                }
                return nRow;
            },
            'fnServerData': function(sSource, aoData, fnCallback) {
                $.getJSON(sSource, aoData.concat($('.inputfield').serializeArray()), function(json) {
                    fnCallback(json);
                });
            },
            'fnInitComplete': function() {
                $('div#resultdiv').show('fast', function() {
                    $('#bodydiv').css('padding-bottom', '0px');
                    oTable.fnAdjustColumnSizing();
                    oTable.fnLengthChange(25);
                    $('#exportdiv').show('fast');
                    $('#waitimgdiv').fadeOut(1000);
                });
            }
        });
}));
Ideas?

Not getting exact search filter result

$
0
0
Hi,

I am using data-table 1.9.
and am not able to get the exact filter search result.
like in data-table row i have word "Hello Word, Hello Test" and when i type "Hello W" in search filter its not filtering the result.

Refresh button for ajax

$
0
0
How can I add a "Refresh" button to TableTools for a table that uses ajax to retrieve data? something like...

   "aButtons": ["refresh",
             "copy","csv","pdf"]

Datatbles Integration with Ace Admin Theme

$
0
0
Hi Allan,

Great Plugin..Thanks For this awesome tool.

One problem is driving me nuts and I have searched entire web but couldn't find any solution.Kindly help.I have integrated vertical scrollable datatables(server side using sAjaxSource) with Ace Admin theme for reponsiveness(bootstrap,ace.min.css/js) files etc.

The moment I integrated it with Ace theme for responsiveness it displays 2 theads.The 2nd thead is static one which displays only sorting icons that do not work but the 2nd header is properly aligned.

The first thead which is formed as a result of aocolumns attribute of datatbles is not at all properly aligned and is not at all responsive.

I have tried all solutions to remove that header like 1)using fnColumnAdjustSizing 2)a div outside table 3)border property set to seperate and all 4)using callbacks all possible solutions but of no help.


Please Help.You are the last hope.

Here's the video url of datatbles.You can see a blank line below the main header.I have hidden it using visibility:hidden as of now
http://screencast.com/t/48bP7ypIkzJ

Client-side filtering on cells with drop down list and ampersand character

$
0
0
Howdy,

I have a table that has three columns. Each column has either an input or a select element inside. I am having trouble with the data table's native client-side filtering functionality. Datatable can't seem to filter on the column with the select element, or on the first row's last column value because of the greater than symbol which get parsed to &lt; . For example, filtering for "Category" or for "Product" does not filter the table to one row.
Here is my JsFiddle : http://jsfiddle.net/39hQK/7/

Using a lot of console.log's I believe I have traced the error down to Datatable's function _fnBuildSearchRow

Javascript for Datatables _fnBuildSearchRow:
function _fnBuildSearchRow( oSettings, aData )
{
   var sSearch = aData.join('  ');
   /* If it looks like there is an HTML entity in the string, attempt to decode it */
   if ( sSearch.indexOf('&') !== -1 )
	{
		 sSearch = $('<div>').html(sSearch).text();
	}
			
	// Strip newline characters
	return sSearch.replace( /[\n\r]/g, " " );
}

Removing the IF block allows me to filter using "Product".
Creating HTML elements from the individual aData array values and grabbing the selected option for the drop down allows me to filter on "Category".

However, modifying the _fnBuildSearchRow function in these two ways causes problems when filtering on tables that do not have input or select elements inside the column cells.

Detecting when a row is selected (single row)

$
0
0
Hi,

I'm looking to display information on a secondary div when a row is selected. Be aware that the data use ajax to retrieve data, therefore I can't use the...

$("#HomeSprintsT tr").click( function( e ) {
          updateDiv(id);
          });
 

since tr is not created until data is received!

I also tried


            "sAjaxSource": "Data.php?tbl=5&",
            "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
              //Add Click event
              nRow.click(function(e){
                  updateDiv(nRow.id);
             });  
            } 

with no success...

Exact column matching problem

$
0
0
Hi,

I am trying to filter my results by values in column 0. For your information column 0 holds a unique call reference number in my table.

$(document).ready(function() {
oTable = $('.dataTable').dataTable();
oTable.fnFilter(100, 0, true, false, false);
} );

The above should only display results with a reference number of 100. However it displays results like 100, eg "100" , "10000" "1000001"

I have also tried

oTable.fnFilter("^"+100+"$", 0, true, false, false);

however this returns "No matching records found"

Thanks in advance for your help.

Dan

mRender - warning: DataTables warning (table id = 'Clientes'): Requested unknown parameter 'Bac'

$
0
0
This page runs in my intranet, so I can not post a direct link.

Here is the HTML:
<table id="Clientes" class="table table-striped table-bordered">
  <thead>
    <tr>
      <th>Id</th>
      <th>Apelido</th>
      <th>Telefone</th>
      <th>SMS</th>
      <th>Bac</th>
      <th>Jun</th>
      <th>Por</th>
      <th>F10</th>
      <th>Painel</th>
      <th>Extra</th>
    </tr>
  </thead>
  <tbody>
  </tbody>
</table>

And here is the JS:
  $('#Clientes').dataTable({
    "bPaginate": false,
    "bProcessing": true,
    "sAjaxSource": 'Ajax.php?O=CadCli',
    "bLengthChange": true,
    "bAutoWidth" : false,
    "aoColumnDefs": [
      {"aTargets": [0],
       "mData": "Id",
       "sWidth ": "40px",
       "sClass": "Centralizado"},
      {"aTargets": [1],
       "mData": "Cli"},
      {"aTargets": [2],
       "mData": "Tel",
       "sWidth ": "50px",
       "sClass": "Centralizado",
       "bSortable": false},
      {"aTargets": [3],
       "mData": "Sms",
       "sWidth ": "50px",
       "sClass": "Centralizado",
       "bSortable": false},
      {"aTargets": [4],
       "mData": "Bac",
       "sWidth ": "50px",
       "sClass": "Centralizado",
       "bSortable": false,
       "mRender": function(data, type, row){
         //console.log(data, ' - ', type, ' - ', row);
         if (data == "S") {
           return '<i class="icon-ok"></i>';
         }
      }},
      {"aTargets": [5],
       "mData": "Jun",
       "sWidth ": "40px",
       "sClass": "Centralizado",
       "bSortable": false},
      {"aTargets": [6],
       "mData": "Por",
       "sWidth ": "50px",
       "sClass": "Centralizado",
       "bSortable": false},
      {"aTargets": [7],
       "mData": "VerF10"},
      {"aTargets": [8],
       "mData": "VerPai"},
      {"aTargets": [9],
       "bVisible": false,
       "mData": "Sta"}
    ],
    "oLanguage": {
      "sProcessing":   "Processando...",
      "sLengthMenu":   "Mostrar _MENU_ registros",
      "sZeroRecords":  "Não foram encontrados resultados",
      "sInfo":         "Mostrando de _START_ até _END_ de _TOTAL_ registros",
      "sInfoEmpty":    "Mostrando de 0 até 0 de 0 registros",
      "sInfoFiltered": "(filtrado de _MAX_ registros no total)",
      "sInfoPostFix":  "",
      "sSearch":       "Buscar:",
      "sUrl":          "",
      "oPaginate": {
          "sFirst":    "Primeiro",
          "sPrevious": "Anterior",
          "sNext":     "Seguinte",
          "sLast":     "Último"
      }
    }
  });

And the debug URL:

http://debug.datatables.net/opimiz

Datatables 1.9.4 with jQuery fstoke window plugin

$
0
0
Hi Allan,
I am using server side Datatables with Scroller inside a window (jQuery fstoke window plugin). When the window is resized, the Scroller (sScrollY) and Datatables height do not get resized accordingly. I had to explicitly assign heights on resize. Can you let me know if you could fix this compatibility? Thanks.

How to disable fnFilter searching on hidden columns

$
0
0
I am working on something very similar to this (http://datatables.net/examples/api/multi_filter.html), however I have at least two hidden columns with IDs that might not necessarily have to be on the first columns and fnFilter seems to pick them up messing up my input box indexes.
Is there any way to avoid this? I tried using bSearchable but no luck :c

Thx!

Regarding Passing parameter to servlet in Datatable

$
0
0
Hi do I pass parameter to a servlet and get the JSONArray to display it in Datatable, my code looks like the following. But currently it doesnt return any value, servlet doesn't recognise the do_action parameter I am passing it to, I am building JSONArray by check this parameter in the servlet. Any One throw some light on how this can be done.



JSP CODE:
   $(document).ready(function() {
	  var oTable = $('#tableId').dataTable( {
	  "bprocessing": true,
	  "bServerSide": true,
	  "sAjaxSource": "/umResourceRequestController?do_action=listUsers",
	  "aoColumns": [
		                { "mData": "appInstance" },
		                { "mData": "usrId" },
		                { "mData": "loginId" },
		            ]
	  });
   });



Servlet Code:

//List User
            if ( do_action.equals("listUsers")){
            	
            	ArrayList<RPUserBean> userlist = new RPUserDAO().getrpUserList(connection);
            	Gson gson = new Gson();
               	JsonElement element = gson.toJsonTree(userlist, new TypeToken<ArrayList<RPUserBean>>() {}.getType());
                JsonArray jsonArray = element.getAsJsonArray();
               	response.setContentType("application/json");
            	response.getWriter().print(jsonArray);


Custom render column

$
0
0
I'm really new to the whole ajax and datatables. And i'm sure there's something somewhere I'm just not seeing it. I'm wanting to make a column of epoch time stamps to render on datatables as a date not an epoch time. Any help with this would be appreciated. Mainly because I can sort epoch time for dates easier than date format 'Jun 15 2013' .

API Using own fields

$
0
0
I am trying to figure out the api so I can use my own field for the number of records pulldown

I have been able to do this with the filter by using:

HTML

<input type="text" id="myInputTextField">

JS

oTable = $('#myTable').dataTable();
$('#myInputTextField').keyup(function(){
oTable.fnFilter( $(this).val() );
})

I can't seem to figure out how to do this for the records per page pulldown. I have:

var oTable = $('#example').dataTable();
$('#myNumber').keypress(function(){
oTable.sLengthMenu( $(this).val() );
})

and then the html markup

<select name='myNumber' id='myNumber'>
<option value="10">10</option>
<option value="20">20</option>
<option value="30">30</option>
</select>

But it is not working.

Data Table sorting is changing the layout of the table.

$
0
0
I am creating a Data table with fixed columns. I am facing problems while sorting. After sorting a column, the layout of table changes. {lease help ASAP.

debug code: epopuv.

How to show a dialog on icon click event inside a cell in Datatable?

$
0
0
In my datatable custom directive, I have three action icons in a cell.
 var oTable = $(elem).dataTable({
            'bJQueryUI':false,
            'sScrollY': '300px',
            'bScrollInfinite':true,
            'bSearchable':true,
            'bScrollCollapse':true,
            'sDom': 'tSi',
            "bDeferRender": true,
            'bPaginate': true,
            'aaSorting': [[1, 'asc']],
            'aaData': scope.datasource,
            "fnRowCallback" : processRow,
            "aoColumnDefs": [
                                {"bSortable": true, "bSearchable": true, "sWidth":"20%", "sTitle" : "Name", "sName": "name",  "aTargets": [ 0 ], "mData":"name", 
                                    "mRender": function ( data, type, full ) {
                                                    return '<a href="#/Attachments/'+full.id+'">'+  data +' </a>';
                                                }
                                },
                                {"bSortable": true, "bSearchable": true, "sWidth":"18%", "sTitle" : "Types", "sName": "types", "aTargets": [ 1 ], "mData":"types" },
                                {"bSortable": true, "bSearchable": true, "sWidth":"10%", "sTitle" : "File Type", "sName": "fileType",  "aTargets": [ 2 ], "mData": "fileType" },
                                {"bSortable": true, "bSearchable": true, "sWidth":"18%", "sTitle" : "Modified Time", "sName": "modifiedTime",  "aTargets": [ 3 ], "mData": "modifiedTime"},

                                {"bSortable": false, "bSearchable": true, "sWidth":"25%", "sTitle" : "Action Buttons", "aTargets": [ 4 ], "mData": "",
                                    "mRender": function ( ) {
                                                    return '<div class = "center"><span><i class = "glyphicon-info-sign glyphicon" id="info" style="color:#32a5e8" onmouseover="this.style.color=\'crimson\'" onmouseout="this.style.color=\'#32a5e8\'"></i></span>      <i class = "glyphicon-edit glyphicon" style="color:#32a5e8" onmouseover="this.style.color=\'crimson\'" onmouseout="this.style.color=\'#32a5e8\'" ng-click=""></i>      <span><i class = "glyphicon-remove glyphicon" style="color:#32a5e8" onmouseover="this.style.color=\'crimson\'" onmouseout="this.style.color=\'#32a5e8\'" ng-click=""></i></span></div>';
                                                }
                                }
                            ]
        })

After clicking on "info" icon, I need to show a message in popover. How to do this?

Sort not working with server side processing and question how to prefilter

$
0
0
Hello,

I'm trying to rebuild an existing result list with the help of DataTables. It looks amazing and I think there is only a small problem but I have problems to solve it myself. So I would like to ask you for help. Thanks in advance ;)

Please have a look at my example: http://bit.ly/1aHUi98

First problem: When I click the columns to sort, it will not work. Also the default sort is not working.

Second problem: I would like to know how I can prefilter (with the help of $_POST) the content, so that only records with the matching ak = "AK30" will be displayed.

Thanks!

		<script type="text/javascript" charset="utf-8">
		
		var oTable;
 
/* Formating function for row details */
function fnFormatDetails ( nTr )
{
    var aData = oTable.fnGetData( nTr );
    var sOut = '<table cellpadding="12" cellspacing="0" border="0" style="padding-left:50px;">';
    // sOut += '<tr><td>Feld 0:</td><td>'+aData[0]+'</td></tr>';
    sOut += '<tr><td>Feld 1:</td><td>'+aData[1]+'</td></tr>';
    sOut += '<tr><td>Feld 2:</td><td>'+aData[2]+'</td></tr>';
    sOut += '<tr><td>Feld 3:</td><td>'+aData[3]+'</td></tr>';
    sOut += '<tr><td>Feld 4:</td><td>'+aData[4]+'</td></tr>';
    sOut += '<tr><td>Feld 5:</td><td>'+aData[5]+'</td></tr>';
    sOut += '<tr><td>Feld 6:</td><td>'+aData[6]+'</td></tr>';
    sOut += '<tr><td>Feld 7:</td><td>'+aData[7]+'</td></tr>';
    sOut += '<tr><td>Feld 8:</td><td>'+aData[8]+'</td></tr>';
    sOut += '<tr><td>Feld 9:</td><td>'+aData[9]+'</td></tr>';
    sOut += '<tr><td>Feld 10:</td><td>'+aData[10]+'</td></tr>';
    sOut += '<tr><td>Feld 11:</td><td>'+aData[11]+'</td></tr>';
    sOut += '<tr><td>Feld 12:</td><td>'+aData[12]+'</td></tr>';
    sOut += '<tr><td>Feld 13:</td><td>'+aData[13]+'</td></tr>';
    sOut += '<tr><td>Feld 14:</td><td>'+aData[14]+'</td></tr>';
    // sOut += '<tr><td>Rendering engine:</td><td>'+aData[2]+' '+aData[5]+'</td></tr>';
    // sOut += '<tr><td>Link to source:</td><td>Could provide a link here</td></tr>';
    // sOut += '<tr><td>Extra info:</td><td>And any further details here (images etc)</td></tr>';
    sOut += '</table>';
     
    return sOut;
}
 
$(document).ready(function() {
    oTable = $('#example').dataTable( {
		// "sDom": 'T<"clear spacer"><"H"TCfr>t<"F"ip>',
		// "sDom": 'T<"clear spacer"><"H"Cfr>t<"F"ip>',
		"sDom": 'Tf<"clear spacer"><"H"lCr>t<"F"ip>',
		"bJQueryUI": true,
		"bProcessing": true,
		"bServerSide": true,
		"sAjaxSource": "server_processing_detail.php",
		"aoColumns": [
			{ "sClass": "center", "bSortable": false },
			{ "sClass": "center" },
			{ "sClass": "center" },
			null,
			null,
			{ "bVisible": false },
			null,
            null,
            null,
            null,
            null,
            null,
            { "bVisible": false },
            { "bVisible": false },
            { "bVisible": false },
            { "bVisible": false },
            { "bVisible": false },
            { "bVisible": false },
            { "bVisible": false },
            { "bVisible": false }
        ],
        "aaSorting": [[1, 'asc']],
		"sPaginationType": "full_numbers",
		"oColVis": {
			"buttonText": " <b>Spalten wählen</b> ",
			"bRestore": true,
			"sRestore": " zurücksetzen ",
			"aiExclude": [ 0, 1, 2, 3, 4 ]
        },
		"oTableTools": {
						"aButtons": [
							{
								"sExtends": "xls",
								"sButtonText": "Als CSV speichern"
							},
							{
								"sExtends": "print",
								"sButtonText": "Druckansicht"
							}
						]
					},
		"oLanguage":
					{
					"sProcessing": "Bitte warten...",
					"sLengthMenu": "_MENU_ Eintr&auml;ge anzeigen",
					"sZeroRecords": "Keine Eintr&auml;ge vorhanden.",
					"sInfo": "_START_ bis _END_ von _TOTAL_ Eintr&auml;gen",
					"sInfoEmpty": "0 bis 0 von 0 Eintr&auml;gen",
					"sInfoFiltered": "(gefiltert von _MAX_  Eintr&auml;gen)",
					"sInfoPostFix": "",
					"sSearch": "Suchen",
					"sUrl": "",
					"oPaginate": {
						"sFirst":    "Erste",
						"sPrevious": "Zur&uuml;ck",
						"sNext":     "N&auml;chste",
						"sLast":     "Letzte"
					}
}
    } );
     
    $('#example tbody td img').live( 'click', function () 
	{
        var nTr = $(this).parents('tr')[0];
        if ( oTable.fnIsOpen(nTr) )
        {
            /* This row is already open - close it */
            this.src = "media/images/details_open.png";
            oTable.fnClose( nTr );
        }
        else
        {
            /* Open this row */
            this.src = "media/images/details_close.png";
            oTable.fnOpen( nTr, fnFormatDetails(nTr), 'details' );
        }
    } );
} );


/*
Funktion um Spalten per Link einzublenden
*/
function fnShowHide( iCol )
{
	var oTable = $('#example').dataTable();
	var bVis = oTable.fnSettings().aoColumns[iCol].bVisible;
	oTable.fnSetColumnVis( iCol, bVis ? false : true );
}

		</script>
Viewing all 1816 articles
Browse latest View live