Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all 82676 articles
Browse latest View live

Cannot read property of mData from calculated property

$
0
0
I have a calculated property on an object that I'm creating like this

Object.defineProperty(batchCompleted.prototype, 'formattedStartDate', {
        get: function() {
            var start = this.start;
            var value = moment.utc(start).format(dateTimeFormat);
            return value;
        }
    });

Then I'm attaching it using mData like this
{
                    aTargets: [5],
                    sTitle: 'Received',
                    sType: "date",
                    mData: 'formattedStartDate'
                },

But when I try and pull up the datagrid it tells me it can't find the column. It seems as if the culprit is in here

 var aDataIn = ($.isArray(aDataSupplied)) ?
            aDataSupplied.slice() :
            $.extend( true, {}, aDataSupplied );

The $.extend removes my columns from the object. Any ideas?

AJAX source - array of objects with sub-object

$
0
0
Hi,

Can datatable handle an array of object with 1 column that is a sub-onject?

I've read the example with sub-array, and i was wondering if is possible to do something like this:
(see the "details" filed, it has braces not square brackets)

 
$(document).ready(function() {
    var oTable = $('#example').dataTable( {
        "bProcessing": true,
        "sAjaxSource": "sources/objects_subarrays.txt",
        "aoColumns": [
            { "mData": "engine" },
            { "mData": "browser" },
            { "mData": "platform" },
            { "mData": "details.0" },
            { "mData": "details.1" }
        ]
    } );
} );


{
  "aaData": [
    {
      "engine": "Trident",
      "browser": "Internet Explorer 4.0",
      "platform": "Win 95+",
      "details": {
        id_details: "4",
        name_details: "X"
      }
    }
....


Why i ask you this? Because i have an entity on my db, for example "engine", that has a field that is a foreign key to an other table, for example "details"..

the db structure is:

Table Engine:
engine char
browser char
platform char
id_details integer

Table Details:
id  integer
name char

Assuming the db structure above, i've created 2 java class, one for "engine" and one for "details". The "engine" class have the filed id_details defined as "details class".

when i send the json to the datatable, the "details" filed it's formatted with braces because it's an object and not a string.

Cna datatable handle this object with a sub-object?
Any suggestion on how handle this?

Kind Regards,

Stefano.

Equivalent of oTable.fnSettings().fnRecordsDisplay()

$
0
0
I don't see how to get the recordsDisplay with the new API ? Is there a direct way ?
By the way, my table's data is dynamic (ajaxed)

Thanks

Yet Another DataTables Column Filter - (yadcf)

$
0
0
Hi,

Just wanted to say that I've finally finished my column filter plugin for datatables.

It's called "Yet Another DataTables Column Filter" or in short "yadcf"


I started to develop it for my own use and at some point decided to release its as plugin...


Here a kickoff example: http://jsbin.com/esezof/1

Here the github page: https://github.com/vedmack/yadcf


And here some info about the features:


*Parsing various types of columns:

plain text
plain text with delimiter
one or more HTML elements with the ability to extract text / value / id from each HTML element

*CSS support:

each filter element has got a css style class , so its style can be easily overridden
Reset button for filter:
next to each filter a reset button will appear (this button allows the user to reset the filter)

*Filter in use visual notification:

when a certain filter is being used it will be highlighted (the color of highlight can easily be changed with css)

*Miscellaneous:

predefined data source for filter (array of strings)
ability to place the filter in an external html element (for example: inside a div element)
change the filter's default label (Select value, etc)
change the filter's reset button text (x, clear etc)



Usage example:

$(document).ready(function(){
  $('#example').dataTable().yadcf([
    {column_number : 0},
    {column_number : 1, filter_container_id: "external_filter_container"},
    {column_number : 2, data:["Yes","No"], filter_default_label: "Select Yes/No"},
    {column_number : 3, text_data_delimiter: ",", filter_default_label: "Select value"},
    {column_number : 4, column_data_type: "html", html_data_type: "text", filter_default_label: "Select tag"}]);
});


Regards,

Daniel

How to put individual column filter inputs at top of columns?

$
0
0
I've tried to modify the column filter using text box inputs example to move the inputs to the top of the columns as seen here, http://jsfiddle.net/s8F9V/.

It works, but, the inputs now also trigger the column sorting when I click in them. The column header text no longer triggers the sort.

How can I have it such that the column header text triggers the sorting and have the text box input filter the content?

Possibility to drag / drop listitem from outside a datatable to add new column

$
0
0
Hi,

I'm investigating the possibility to add new columns to a datatable by presenting the user a list with available columns that could be added to the table (outside the datatable) and when the user drags one of the listitems over the datatable and drops it, the columns is added to the datatable.

Preferably showing a nice caret at the place where the column will be dropped / added to the table, like for example is done when reordering the columns...

Is something like this possible?
I think I need to make use of some kind of drag event to show the caret and a drop event when the users drops the column to add the column to the table.

thanks in advance,
Richard

How can we enable locking on the editable fields in Data Tables?

$
0
0
I'm currently using jEditable plugin to make some columns in the table editable. However, since the page can be accessed by multiple people at the same time I'm concerned about the consistency issues. Is there a way that you can use the concept of locks for adding data synchronization to the table? Any ideas would be greatly appreciated.

Refresh FixedHeader after change visibility of a column

$
0
0
Hi !

The FixedHeader is not refreshed after change visibility of a column. It's not refresh for <thead> but it's ok for <tfoot>

I try with dataTables 1.9.4 and FixedHeader 2.1.1-dev (I try with this version because http://datatables.net/forums/discussion/19723/fixedheader-2-1-0-plugin-and-invisible-columns-not-working-)

You can test here : http://jsfiddle.net/GQ7j3/

If I click on the button "Hide col 2", the column 2 is hidden but the header is not refreshed for thead tag but the header is refreshed for tfoot tag.

Why I have this problem ?


Thanks

fnDrawCallback function which accepts a callback itself

$
0
0
I have the following:

	var oTable = $('#patient_table').dataTable( {
                 ....
		"fnDrawCallback": loadModalLinks,
	});

loadModalLinks is defined in another js file which is included, loadModalLinks also takes in a callback function via the first argument, how would you write this? I'm also using jquery.

As the following does not work:

...
 "fnDrawCallback": loadModalLinks(function () {})

Sorting with HTML and fnrender

$
0
0
Hello, first of all I'm deeply sorry, cause I think the solution is still there, but I couldn't figure it out. I've tried the plugin-ins, the answers in this forums, even some samples on github crashed my table :-D My request: I want to sort html-columns with the fnrender-function... not as a string, but with nummeric.

My "problem" looks pretty simple: Most of my columns have html-code, which were rendered before, e.g.

 "aoColumnDefs": [ { "fnRender": function ( oObj ) { return '<a HREF="'+ oObj.aData[11]+'" Target="_blank" title="xyz">' + oObj.aData[2] +'</a>'; }, "sType": "html", "bVisible": false, "asSorting": [ "desc" ], "aTargets": [ 2 ] } ]

...basically it's wraps the value with a link from a different column. For some reasons it's not possible combining them before.

With strings, it's no problem, but not with numerics. It sorts - even with numbers - as a string. So datatables sorts it like

9988
99
979

...for sure, it has to be:

9988
979
99

Hopefully there is somebody who could help me. I've already tried http://datatables.net/plug-ins/sorting#numbers_html and http://datatables.net/plug-ins/type-detection#numbers_html but it doesn't work. Maybe I made something wrong.

Sebastian

Getting data for the datatables using WHERE statement then still allow filtering

$
0
0
Hi all,

I am new to DataTables and I am trying to get some data to display. I want to only select data from the db WHERE field_name IS NOT NULL then be able to filter the results. How do I go about doing this. I have searched and searched but not found anything too helpful. By the way I am a noob so expect stupid questions! haha!

I have added the code below to the processing file:

$sWhereNew = "field_name IS NOT NULL ";

/*
* SQL queries
* Get data to display
*/
$sQuery = "
SELECT SQL_CALC_FOUND_ROWS `".str_replace(" , ", " ", implode("`, `", $aColumns))."`
FROM $sTable
WHERE $sWhereNew
$sWhere
$sOrder
$sLimit

This filters the results and shows at the bottom xxxx results filtered from xxxx but then I cannot use the search bar to filter further. What am I doing wrong?!

Thanks for any help!!

Using JSTL and Spring to Populate a DataTable then Export

$
0
0
Hi there,
I am trying to use DataTables and TableTools to export a table I created using Spring Framework. The table works great, as does TableTools, with the exception of one pestering bug. When I am traversing an Array from Spring, the Copied and Exported values show up multiple columns later. Here is my code:

	<script>
    $(document).ready( function () {
    	  var table = $('#example').DataTable({
				"sDom": 'T<"clear">lfrtip',
				"oTableTools": {
					"sSwfPath": "swf/copy_csv_xls_pdf.swf",
				     "mColumns": "visible"
				}	  
    	  })
    	   .on('mousedown', '.hasTooltip', function(event) {
        $(this).qtip({

    

            hide: {
                event: 'unfocus',
                inactive: 2000,
                effect: function() {
                    $(this).slideUp();
                }
            },
            style: {
                classes: 'qtip-bootstrap qtip-shadow'
            },
            overwrite: false,
            content: {
                text: $(this).next('div') // Use the "div" element next to this for the content
            },
            show: {
                event: event.type,
                ready: true
            }
        });
    });
    	} );
	</script>	




		<div class="container">
			<table id="example" class="display">
			    <thead>
			        <tr>
			            <th>Nickname</th>
			            <th>Location</th>
			            <th>Site</th>
			            <th>Type</th>
			            <th>Total</th>
			            <th>Jobs with Failures</th>
			        </tr>
			    </thead>
			    <tbody>

	 			<c:forEach items="${finalSummary}" var="row" varStatus="status">
					<tr>
						<td>
							<div class="hasTooltip">${row.nickname}</div>
						</td>
						<td>${row.site}</td>
						<td>${row.location}</td>
						<td>${row.site}</td>
						<td>${row.type}</td>
						<td>${row.failures}</td>
						<td>
						<c:forEach items="${row.failureJobs}" var="failrow" varStatus="status">
						${failrow}<br></br>
						 </c:forEach>
						</td>
					</tr>
				</c:forEach>
			    </tbody>
			</table>	
		</div>




My problem is, when I go to export, the ${failrow} entries are multiple columns apart rather than being in the same cell. Strangely, this issue only occurs with FireFox and Chrome, but has no issue with IE. Unfortunately, I cannot post an example as the server is hosted internally.

Inserting content between "showing x entries" and filter box

$
0
0
I am new to DataTables .

I managed to plug-in datatables into my code . I have one more requirement which is as follows.

In datatables , I want to add some content (buttons) between "showing x entries"(i.e., div with id:'tableName_length') and filter(i.e., div with id : 'tableName_filter') input box .

Is there any way I can achieve it.

To be specific , I want to insert table tools "select_all" and "select_none" buttons and "my_own_button" between those two which I mentioned above . Could any body help me on this ?

Show 10, 25 entries not working in IE 8.

$
0
0
Hi,

Following is the code to create my table. I have initialized iDisplayLength to 200. When I click on Show 10, it does nothing, still displays the 200 records. This is happening in IE8, but it works in Chrome. Please advise on how to get this to work on IE8.

(function($) {

var myDataTableDefaults = {
"sPaginationType": "full_numbers",
"iDisplayLength": 200,
"aLengthMenu": [[10, 25, 50, 100, 200, -1], [10, 25, 50, 100, 200, "All"]],
"oLanguage": {
"sSearch": "Filter:"
},
"fnInitComplete": function(oSettings, json) {
$(".loadingPageDomAnimation").hide();
$('.dataTable').fadeIn('slow');
},
"sEmptyTable": "No record found"
};

$.fn.myDataTable = function (options) {
options = $.extendmyDataTableDefaults, options);
return this.dataTable(options);
};
})(jQuery);

Thank you.

How to display search results on another page

$
0
0
I would like to have just a search box with button on one page and have the results be displayed on a search_results.html page. I have the table working fine but this would add another level of functionality. Thanks for any suggestions of for pointing me to a working example. Great use of jQuery to simplify things by the way.

Count of selected rows.

$
0
0
In my code I am using two custom(not table tools provided) buttons which selects and deselects all the rows in table.I am calling fnSelectAll() and fnSelectNone() respectively for those button click callbacks. Also I can induvidually select multiple rows in the table.
Is there a way/technique through which I can get the count of selected rows ? Could any one help me on this ?
I tried to implement it with one variable which gets incremented when I select any row (I am incrementing the count at fnRowSelected callback) and gets decrement when I de-select any row (I am decrementing the count at fnRowDeselected callback). As I am implementing custom buttons to select and deselect all I tried the same in those button click callbacks also . But it didn't work.

Basic FixedColumns Setup

$
0
0
Hi! I am having a problem getting FixedColumns setup properly. Here is my example: http://live.datatables.net/wikoled/3/edit. I'm just trying to freeze one left column using semi-real data, but I'm not getting a fixed column at all. Instead, all columns are scrolling along the x axis. Any advice would be appreciated!

Thanks,
Sharon

Need to access accordion hidden rows

$
0
0
I currently have a table that uses the accordion feature. If 200 rows load only 10 are shown at a time. Each row has a checkbox so a user can select the row. Works great except when a user selects some rows, paginates to a new page and then selects some more rows. If I paginate back and forth I see all the row are still selected. When I go to find out how many rows have been selected by code only returns the ones that are visible.

This is the line of code I currently use to get me a list of selected rows:
var selectedLogIds = $('#wellList .pdsSubTable').find('input:checked').map(function(i, item) { return item.value; }).get();

Is there a setting somewhere to allow this to return even the selected rows that are not actively being displayed?

the sDom parameter

$
0
0
Hi Allan,

I don't fully understand the sDom syntax. Take your example:

"sDom": '<"top"i>rt<"bottom"flp><"clear">'

How do I read this?

I understand the letters as identifying parts of the table elements, but

< and > - div elements
<"class" and > - div with a class

is really not clear to me!

Thanks,
Martin

Issue using 1.10 table rows()

$
0
0
I've encountered an issue when attempting to follow the example for multi-row selections:

https://next.datatables.net/examples/api/select_row.html

The issue is, when I try to recreate the example and click the button nothing happens. The console shows the following error:

Uncaught TypeError: Object [object Object] has no method 'rows'

I've checked and made sure I'm not loading multiple instances of jQuery or datatables JS files. See the jsfiddle at:

http://jsfiddle.net/8HPh4/14/

Is this possibly a bug, or have I botched something here? I've tried using jQuery 1.10.2, 1.11.0, but encountered the same issue.
Viewing all 82676 articles
Browse latest View live