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

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?

Fixed column size

$
0
0
Does anyone know how to fix left column widths so that they do not stretch, I tried using the plugin FixedColumns but we are hiding rows and columns, this plugin creates a clone of the columns to set the width and breaks our existing code. It seems like it should be a very simple thing to have col 1 width is 20 and col 2 width is 100 and not stretch. Is that possible?

Footer callbacks and multiple rows

$
0
0
Hi Guys

I started playing with callbacks today, mainly to calculate some column totals on redraw so I've been using the fnFooterCallback function. I have it working great totaling up some columns, but my question is, does the callback support multiple <tr>s in a <tfoot> ? I'd like to have subtotals for each column in one row in the footer and then some group totals in another. Can the callback handle that?

Thanks
Paul

Vertical Scrolling problem in IE

$
0
0
I am using Datatable JQuery version 1.9.3.

I set some properties and tested on Chrome and Firefox. When came to IE 8 or lesser versions, vertical scrolling doesn't work. If sScrollY and bScrollCollapse are set, then only this happens in IE .

What should i do to overcome this problem.

Please help me out.

Sorting 1100 rows extremely slow ~20 mins

$
0
0
Hi, I'm experiencing a strange problem where trying to sort any columns results in about a 20 minute wait period. After it is done processing, the columns can be sorted instantly. This is strange because it is only 1100 rows. I greatly appreciate any help on this. I'm using Ajax / server side processing. Also, the search and pagination have almost no delay. Why would sorting be so slow? I'm using Ruby/Rails.

I will be happy to make a donation to the project for any support!

$("#datatable").dataTable({
    "bJQueryUI": true,
    "sPaginationType": "full_numbers",
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": $('#datatable').data('source'),
    "bAutoWidth": true
});

$.extend( $.fn.dataTableExt.oStdClasses, {
    "sSortAsc": "header headerSortDown",
    "sSortDesc": "header headerSortUp",
    "sSortable": "header"
} );
--
class ClientsDatatable
  delegate :params, :h, :link_to, :mail_to, :number_to_currency, to: :@view

  def initialize(view)
    @view = view
  end

  def as_json(options = {})
    {
      sEcho: params[:sEcho].to_i,
      iTotalRecords: Client.count,
      iTotalDisplayRecords: clients.total_entries,
      aaData: data
    }
  end

  private

  def data
    clients.map do |client|
      [
        client.first_name,
        client.middle_name,
        client.last_name,
        client.employer,
        client.account_number,
        mail_to(client.email.downcase, client.email.downcase),
        client.account_status,
        Client.find_user_name_by_id(client.broker_id),
        client.date_updated,
        link_to('Show', client),
        link_to('Edit', "clients/#{client.id}/edit"),
        link_to('Destroy', client, method: :delete, data: { confirm: 'Are you sure?' })
      ]
    end
  end

  def clients
    @clients ||= fetch_clients
  end

  def fetch_clients
    clients = Client.order("#{sort_column} #{sort_direction}")
    clients = clients.page(page).per_page(per_page)
    if params[:sSearch].present?
      clients = clients.where("last_name like :search or first_name like :search", search: "%#{params[:sSearch]}%")
    end
    clients
  end

  def page
    params[:iDisplayStart].to_i/per_page + 1
  end

  def per_page
    params[:iDisplayLength].to_i > 0 ? params[:iDisplayLength].to_i : 10
  end

  def sort_column
    columns = %w[last_name]
    columns[params[:iSortCol_0].to_i]
  end

  def sort_direction
    params[:sSortDir_0] == "desc" ? "desc" : "asc"
  end
end
--
<table id="datatable" data-source="<%= clients_url(format: "json") %>">
  <thead>
  <tr>
    <th>First name</th>
    <th>Middle</th>
    <th>Last name</th>
    <th class="span2">Firm</th>
    <th class="span1">Account number</th>
    <th>Email</th>
    <th>Account status</th>
    <th>Broker Name</th>
    <th>Date updated</th>
    <th>Show</th>
    <th>Edit</th>
    <th>Delete</th>
  </tr>
  </thead>
  <tbody>

  </tbody>
</table>

sAjaxSource does not fire when using IE8. It is ok with IE9 >

$
0
0
Hello All,

Call to sAjaxSource does not fire at all when using IE8. Seems ok on IE9.
This is the link... www.jobphi.com, click on "Links" menu to see the issue.

I tried so many things but no luck. Also, I have seen others having same issue, but no solution fits me.
Debug Code: uwojot

Thanks

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?

jquery datatable highlight row selection issue in MVC application

$
0
0
I am using jquery datatable to show my table (Client side) in MVC application. I am using below example to highlight selected row.

http://www.datatables.net/beta/1.9/examples/api/select_single_row.html

The script basically adding or removing “row_selected” class from the row based on clicked. The script is executed but row is not highlighted.

Do I need to manually create a css “row_selected” ??
If no, then, where is this class define ? Or what am I doing wrong ? what is best solution ?
If yes, then, can you suggest example ?
Thanks in advanced.

 

_Layout.cshtml:-

<head>
    <meta charset="utf-8" />
    <title>@ViewBag.Title</title>

    @Content.Css("DataTables-1.9.4/media/css/demo_page.css", Url)
    @Content.Css("DataTables-1.9.4/media/css/demo_table.css", Url)
    @Content.Css("DataTables-1.9.4/media/css/demo_table_jui.css", Url)
    @Content.Css("themes/base/jquery.ui.all.css", Url)

    @Content.Css("Site.css", Url)
    @Content.Script("jquery-1.5.1.min.js", Url)
    @Content.Script("jquery-ui-1.8.11.min.js", Url)
    @Content.Script("DataTables-1.9.4/media/js/jquery.dataTables.min.js", Url)
    @Content.Script("modernizr-1.7.min.js", Url)
    @Content.Script("jquery.unobtrusive-ajax.min.js", Url)
</head>


Index.cshtml :- Render partial view where table is defined

@model IEnumerable<User>

<div>
    @Html.Partial("_List", Model)
<div>


_List.cshtml:- 

@model IEnumerable<User>

<div>  
<table id="jquey-datatable">
    <thead>
        <tr>
            <th>***</th>
            <th>***</th>
            <th>***</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
        <tr>
            <td>***</td>
            <td>***</td>
            <td>***</td>
        </tr>
        }
    </tbody>
</table>
</div>

<script type="text/javascript">
    var oTable;

    $(document).ready(function () {

        $('#jquey-datatable tbody tr').click(function (e) {
            alert ("Start...);
            if ($(this).hasClass('row_selected')) {
                $(this).removeClass('row_selected');
            }
            else {
                oTable.$('tr.row_selected').removeClass('row_selected');
                $(this).addClass('row_selected');
            }
            alert ("Finish...);
        });

        oTable = $('#jquey-datatable').dataTable({
            "bJQueryUI": true,
            "sPaginationType": "full_numbers",
            "sScrollY": 200,
            "sScrollX": "100%",
            "bScrollCollapse": true
        });
    });
</script>

unable to get column Index to remove the column from data Table1.9

$
0
0
hai to all,
here my requirement is removing a column from data table using drag and drop on treeview ;i am unable to get the column Index here;please guide me how to acheive this;If i need any api's guide me how to add it;here is my code:
<head runat="server">
<title></title>
<style type="text/css" title="currentStyle">
@import "../DataTabels/demo_table.css";
</style>
<script src="Scripts/JQuery1.9.1.js" type="text/javascript"></script>
<script src="DataTabels/jquery.dataTables.js" type="text/javascript"></script>
<script type="text/javascript" src="DataTabels/ColReorder.js"></script>
<script src="DataTabels/DragandDrop.js" type="text/javascript"></script>
<script src="Scripts/jquery.dndtable.js" type="text/javascript"></script>
<script src="DataTabels/ColVis.js" type="text/javascript"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css&quot; />
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js&quot; type="text/javascript"></script>
<script type="text/javascript">
debugger;
$(document).ready(function () {
$(".treeNode").draggable({ helper: 'clone' });
$("#droppable").droppable({
drop: function (event, ui) {
var columnName = $(ui.draggable).text();
var mytable = $("#sampleTable").dataTable(),
iter = 0;
//adding dragged treeview Node as column in data table
mytable.find('tr').each(function () {
var trow = $(this);
if (trow.index() === 0) {
trow.append('<th >' + columnName + '</th>');
}
else if (trow.index() >= 1) {
trow.append('<td> Acer </td>');
}
iter += 1;
});
var oTable = $("#sampleTable").dataTable();
oTable.fnDestroy();
//displaying Data
$("#sampleTable").dataTable();

}
});

});

$(document).ready(function () {
$("#sampleTable tr ").draggable({
cursor: 'move',
stack: $('#TreeviewDiv')
});

$("#TreeviewDiv").droppable({
drop: function (event, ui) {

var oTable = $("#sampleTable").dataTable();
//when i dropped on treeview Data Table column has to be delete.
//getting position of column
var aPos = oTable.fnGetPosition(this);
// var aPos = oTable.fnGetPosition($("thead tr").index(this));
$.fn.removeCol = function (col) {
if (!col) { col = 1; }
$('tr td:nth-child(' + col + '), tr th:nth-child(' + col + ')', this).remove();
return this;
};
$('#sampleTable').removeCol(aPos);
}
});
});

</script>
</head>
<body>
<form id="form1" runat="server">
<div id="TreeviewDiv">
<asp:TreeView ID="TreeView1" runat="server" ImageSet="BulletedList3">
<Nodes>
<asp:TreeNode Text="AccountGeneral" Value="AccountGeneral">
<asp:TreeNode Text="AccountOwner" Value="AccountOwner"></asp:TreeNode>
<asp:TreeNode Text="CreatedBy" Value="CreatedBy"></asp:TreeNode>
</asp:TreeNode>
</Nodes>
<NodeStyle CssClass="treeNode" Font-Names="Verdana" Font-Size="8pt" ForeColor="Black"
HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" />
<ParentNodeStyle Font-Bold="True" ForeColor="#5555DD" />
<SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px" VerticalPadding="0px" />
</asp:TreeView>
</div>
<div>
</div>
<br />
<div id="droppable">
<table id="sampleTable">
<thead><tr> <th>AccountType</th> <th>AccountName</th> </tr></thead>
<tbody>
<tr> <td> New</td> <td> Name1 </td> </tr> <tr> <td> Lead </td> <td> Name2 </td></tr> <tr><td>test </td><td> Name3 </td></tr>
</tbody>
</table>
</div>
</form>
</body>

Rendering issue when using Fixed Columns with IE 7

$
0
0
Hi, I've got an issue with the rendering of rows not lining up properly in IE7 (and IE8 Compat View).

I'm using Fixed Columns, as you can see below:
http://live.datatables.net/uxolog/1

I've basically got 14 columns, the left 4 fixed in place.

It renders fine in IE10 in Standards mode as well as in Chrome.

Here's a screenshot taken in IE7 - http://imgur.com/tGAwtYJ

Also, here is the DataTables debug: http://debug.datatables.net/adugig
Note, the debug was done with a local version of DataTables with FixedColumns 2.0.3.

I can re-run the debug with the nightly if you wish.

Thanks,


Will

IE 7/8 Page Button Strange Behavior

$
0
0
In IE 7 and 8 using server side paging, the "Next" button behaves like the "First" button, the "First" button behaves like the "Previous" button and the "Previous" button behaves like the "Next" button. Has anyone run into this and what was the fix?

Server-side processing to C# and values GET

$
0
0
Hello, I am starting a project using C # and DataTables. Net

I'm finding it very interesting project, but I have a doubt on how to use DataTables server-side processing, because of the parameters that DataTables sends Ajax.

I need to know when the user sort a column, know her name and not her number. If I know the name, my job can be more generic.

The parameter mDataProp_(int) used for this? I can get the name of a column by its id?
Prior had "sColumns" but it is obsolete now ...

tks

JQuery DataTable Column Filter - External Form - pre-selected filter

$
0
0
Hi,

we use the Query DataTable Column Filter Plugin (External Form)
http://jquery-datatables-column-filter.googlecode.com/svn/trunk/external.html]
to get our data filtered. Example:
{ type:"select", sSelector: "#Filter", values: ['Option1', 'Option2', 'Option3'] }

I would like to set the first Option as default (not "All"), Option2 (and Option 3 and so on) should be a subset of Option1 (that means it should filter the data for two key words (Option1 and Option2 ) but should only show Option2) and the All-Option (unfiltered table) should be shown as last one in the list.

Any ideas how to make this work?

Regards, aluscc

Uncaught TypeError: Cannot read property 'className' of undefined

$
0
0
when apply DataTables to the table with a row 'colspan = 7' below, an Error occured: Uncaught TypeError: Cannot read property 'className' of undefined. (I have try it in "DataTables live" and debugger: http://debug.datatables.net/ahiyey)

HTML:
<table id="result_table" class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th width="20px">#</th>
<th>id</th>
<th>stream</th>
<th>dir</th>
<th>plate</th>
<th>time</th>
<th>detail</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="7" class="warning">isok?</td>
</tr>
</tbody>
</table>

The column sorting doesn't work

$
0
0
Hello, guys
The below is my code portion. There are 6 columns in the table, the php file extracts 4 columns from db table, it work well, but If i uncomment the aaSorting": [[2,'desc'], [5,'asc']], it doesn't work , i am new to datatables, is anybody can help me?
$(document).ready(function(){
	  var oTable = $('#example').dataTable({
		//"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
		"sPaginationType": "bootstrap",
				   "sDom": "<'row'<'span7'l><'span7'f>r>t<'row'<'span7'i><'span7'p>>",
					"bProcessing": true,
					"bServerSide": true,
					"bPaginate": true, 
					"sAjaxSource": "showHistoryLog.php",
					"iDisplayLength": 20,
					"aLengthMenu": [[20, 30, 50, -1], [20, 30, 50, "All"]],
					"fnServerParams": function (aoData) {
					      aoData.push( { "name":"pid","value":$('#pid').val()} );
					      aoData.push( { "name":"tid","value":$('#tid').val()} );
					    },
				   
					//"aaSorting": [[2,'desc'], [5,'asc']],
					"oLanguage": {
						"sLengthMenu": "_MENU_ records per page"
					},
					"aoColumns": [
					              //{"mData": null,"sDefaultContent":$('#tname').val()},
					            //  {"mData": null,"sDefaultContent":$('#pname').val()},
					              {"mData": null,"sDefaultContent":$('#tname').val()},
					              {"mData": null,"sDefaultContent":$('#pname').val()},
					              {"mData": "log_date"},
					              {"mData": "log_flag"},
					              {"mData": "log_content"},
					              {"mData": "pod_name"}
					            ]
			});
});
showHistoryLog.php
...
$aColumns = array( 'l.log_flag','l.log_date','l.log_content','f.pod_name');
....
This bellow is used to show the table
..........
<table cellpadding="0" cellspacing="0" border="0" class="table table-bordered table-striped table-hover" id="example" >
	<thead>
		<tr><th>Test Item</th><th>Test Plan</th><th>Log Time</th><th>Status</th><th>Content</th><th>Location</th></tr>
	</thead>
	<tbody>
		<tr>
			<td colspan="6" class="dataTables_empty">Loading data from server</td>
		</tr>
	</tbody>
	<tfoot>
		<tr><th>Test Item</th><th>Test Plan</th><th>Log Time</th><th>Status</th><th>Content</th><th>Location</th></tr>
	</tfoot>
</table>
..........

dataTable, Order By date Help plis!

$
0
0
Good Day for all,
(developing a system based on PHP and ZendFramework)

I'm here to ask for help the you, I have a "problem" in my dataTable, which is the following, I need listing by date one column, ie;

01/02/2013,

02/02/2013,

03/02/2013

Unfortunately, my dataTable is listing per day practically, it lists all the first day, then all two days, after all 3 days and so forth, example;


01/02/2013,

01/03/2013,

01/04/2013,

01/05/2013,

02/02/2013,

02/03/2013,

02/04/2013,

02/05/2013

Even when you can not see a solution.
I'm need help in question,
plis if someone have knowing, post for me plis.

Can anyone explain to me why she is doing the search this way?
or has a solution in mind that can help me.

Sorry, inglish not fluent language.
Thank you in the attention you got to look at this post.

unable to perform drag and drop on Dynamically added columns

$
0
0
hai to all......

here My requirement is: adding and removing column by drag and drop functionality dynamically from treeview to dataTable 1.9;for that i took html table with some static data ;thats i binded to data table;currently i can able to add columns dynamically and i can remove the columns using drag and drop functionality but here is the problem drag and drop functionality is working only for static data; i am working on .net framework 3.5
here is my code:
<head runat="server">
<title></title>
<style type="text/css" title="currentStyle">
@import "../DataTabels/demo_table.css";
</style>
<script src="Scripts/JQuery1.9.1.js" type="text/javascript"></script>
<script src="DataTabels/jquery.dataTables.js" type="text/javascript"></script>
<script src="DataTabels/ColumnIndex.js" type="text/javascript"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css&quot; />
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js&quot; type="text/javascript"></script>
<script type="text/javascript">
debugger;
$(document).ready(function () {
$(".treeNode").draggable({ helper: 'clone' });
$("#droppable").droppable({
drop: function (event, ui) {
var columnName = $(ui.draggable).text() + ' ' + "";
var duplicateCol = $("#sampleTable thead th");
var a = 0;
for (i = 0; i < duplicateCol.length; i++) {
if (duplicateCol[i].innerText.toString() == columnName.toString()) {
a = 1;
break;
}
}
if (a == 0) {
var mytable = $("#sampleTable").dataTable(),
iter = 0;
mytable.find('tr').each(function () {
var trow = $(this);
if (trow.index() === 0) {
//here i added "ui-draggable "class dynamically for making my column DnD;but its not working
trow.append('<th>' + columnName + ' ' + '</th>').addClass("ui-draggable");
}
else if (trow.index() >= 1) {
trow.append('<td> Acer </td>');
}
iter += 1;
});
var oTable = $("#sampleTable").dataTable();
oTable.fnDestroy();
$("#sampleTable").dataTable();
}
else {
$(".treeNode").draggable({ revert: true });
}

}
});

});

$(document).ready(function () {
$("#sampleTable th").draggable({
cursor: 'move',
stack: $('#TreeviewDiv')
});
$("#TreeviewDiv").droppable({
drop: function (event, ui) {
var columnName = $(ui.draggable).select().text();
var oTable = $('#sampleTable').dataTable();
var colIndex = oTable.fnGetColumnIndex(columnName);
alert(colIndex);
var index = colIndex + 1;
$.fn.removeCol = function (col) {
$('tr td:nth-child(' + col + '), tr th:nth-child(' + col + ')', this).remove();
return this;
};
$('#sampleTable').removeCol(index);
}

});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="TreeviewDiv">
<asp:TreeView ID="TreeView1" runat="server" ImageSet="BulletedList3">
<Nodes>
<asp:TreeNode Text="AccountGeneral" Value="AccountGeneral">
<asp:TreeNode Text="AccountOwner" Value="AccountOwner"></asp:TreeNode>
<asp:TreeNode Text="CreatedBy" Value="CreatedBy"></asp:TreeNode>
</asp:TreeNode>
</Nodes>
<NodeStyle CssClass="treeNode" Font-Names="Verdana" Font-Size="8pt" ForeColor="Black"
HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" />
<ParentNodeStyle Font-Bold="True" ForeColor="#5555DD" />
<SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px" VerticalPadding="0px" />
</asp:TreeView>
</div>
<div>
</div>
<br />
<div id="droppable">
<table id="sampleTable">
<thead><tr><th>AccountType </th> <th> AccountName </th></tr></thead> <tbody> <tr><td> New </td> <td> Name1</td></tr> <tr> <td> Lead</td> <td> Name2 </td></tr><tr> <td> test </td><td> Name3 </td> </tr>
</tbody>
</table>
</div>
</form>
</body>
Please guide me if i done wrong ;and suggest me how to resolve the issue.....

Thanks in advance

Using a custom scroller with the Scroller plugin

$
0
0
Hi, I've been using DataTables with jquery.customscroller without a problem until I tried to use the (deferred rendering) Scroller plugin. I think because the rows are not created at the time the custom scroller sets the size of the container to zero and thus all the rows are hidden (they are there in the DOM when I inspect the page). Is there an event that fires after the rows are rendered (when using deferred rendering) that I can hook up to then update the custom scroller?

Possible to set DataTable sorting options via the HTML?

$
0
0
Hi there,

I've got a website with lots of tables, and each one has different columns, column types, etc.

I'm currently calling them all with a single JS call for any table that has a class of 'sortable-table'. This is convenient and means there's less lines of code than if I had calls for every single individual table.

However, I've got half a dozen tables that I want to use aoColumns sType sorting on. In order to do this, I think I'm going to have to have an individual call for these tables in my JS, which is going to be tedious (as each of these tables has different columns).

So my question (finally) is, is it possible to specify these values via classes on the table itself? So rather than use aoColumns and '{ "sType": "uk_date" }, in my functions.js file, can I specify this via the actual table row itself, e.g. <th class="uk_date">Date Submitted</th> or similar?

Thanks,

Ste

Unexpected token

$
0
0
Hi Everybody,

I'm a newbie and I want to know why this code return a unexpected error code message.

Thank's for your help !

$(document).ready( function () {
$('#my-table').dataTable( {



"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"sSwfPath": "copy_csv_xls_pdf.swf"
}
"oLanguage": {
"sUrl": "datatables.french.txt"
}
} );

} );
Viewing all 1816 articles
Browse latest View live