when the user clicks on an inline edit field, the row gets suddenly higher. (newest versions of datatables, editor, bootstrap 4.0 beta) is this a known problem or am I missing something?
bootstrap 4 inline editor changes row height?
How can i bold title in exported excel
How can i bold title in exported excel
Reload static data
I've searched for threads on this but they've been closed without an answer.
I have a static datatable created in html with data populated from a sql database. My table data is not called from ajax.
However, I have an input field which when changed, an ajax call updates the database and I'd like this row to then be removed from the datatable.
Is there a function to reload my static table in the aforementioned ajax success.
Many thanks
Search input
Hi everyone,
my question is, where can I find this Search input so i can implement it outside the table so it can search dynamicly from more then one table at the same time.
Thanks
Armin
Select only two rows
Is it possible to restrict the multi select for two rows?
Ultimate Date Time Search Not Working
Hi Allan,
I'm using your ultimate datetime plugins
The sort function working well, but not on search
My code:
$(function () {
$('#min_date').datetimepicker({
format: 'DD MMM YYYY'
});
});
$(function () {
$('#max_date').datetimepicker({
format: 'DD MMM YYYY'
});
});
$(document).ready(function() {
//define custom date format
$.fn.dataTable.moment('DD MMM YYYY');
// Setup - add a text input to each footer cell
$('#tblProcessDocument tfoot th').each( function () {
var visIdx = $(this).index();
var title = $(this).text();
if (title !==""){
$(this).html(
'<input class="text-warning col-lg-12 col-md-12" type="text" placeholder="'+title+'">'
);
}
} );
var tblProcessDocument = $('#tblProcessDocument').DataTable({
serverSide: true,
scrollX: true,
mark: true,
ajax: "function/log_process_document.php",
columnDefs: [
{
//render: $.fn.dataTable.render.moment( 'YYYY-MM-DD', 'DD MMM YYYY'),
//"targets": 3
}
],
buttons: [
{ extend: "copy", text: '<u>C</u>opy'},
{ extend: "excel", key: 'x' ,text: 'E<u>x</u>cel'},
{ extend: "pdf", key: 'f' ,text: 'pd<u>f</u>'}
],
createdRow: function( row, data, index ) {
if ( data[5] == null )
{
$('td', row).eq(5).addClass('bg-red');
}
}
});
$('#min_date').keyup( function() { tblProcessDocument.draw(); } );
$('#max_date').keyup( function() { tblProcessDocument.draw(); } );
tblProcessDocument.columns().eq(0).each( function ( colIdx ) {
$( 'input', 'th:nth-child('+(colIdx+1)+')' ).on( 'keyup change', function() {
tblProcessDocument
.column( colIdx )
.search( this.value )
.draw();
});
});
} );
please help, this is the live example
thank you
danny
pageLength does not change with custom select
Hi, i have a problem with pagination length.
This is my code:
var table = $('#customerTable').DataTable({
serverSide: true,
rowId: 'id',
destroy : true,
pageLength: $("#test option:selected").val(),
dom: '<"length">Bfrtip',
//dom: 'lBfrtip',
buttons: [
'copy', 'csv', 'excel', 'print'
],
ajax: {
url: "{{ route('ajax-customer') }}"
//dataSrc: ''
},
columns: [
{data: 'id'},
{data: 'email'},
{data: 'phone_number'},
{data: 'first_name'},
{data: 'last_name'},
]
});
//$("div.length").html('<div class="dataTables_length" id="customerTable_length"><select name="customerTable_length" aria-controls="customerTable" class="select2"><option value="10">10</option><option value="25">25</option></select></div>');
$('#test').change(function () {
table.ajax.reload(null,false);
});
Basically, i need to use a value of external select as pageLength. When datetables is init, load the $("#test option:selected").val() value correctly, but when table.ajax.reload(null,false); is called, in the ajax request the page length is the same as the initial request.
Also, i neet to customise the search input, how can i do that?
Changing the text of a button dynamically with rows selected
I have the following code:
$(document).ready(function() {
var table = $('#defTable').DataTable({
select: {
style: 'multi'
},
dom: 'Bfrtip',
buttons: [
{
extend: 'selected',
text: 'Delete',
className: 'delete'
}
]
});
$('#defTable tbody').on('click', 'tr', function(){
var count = table.rows({selected: true}).count();
$('.delete').text('Delete ('+count+')');
});
} );
When I first click on a row, the count shows 0. When I click on another row, count is 1. When I deselect one row, it shows 2.
I understand that this function is being executed before the Select Extension changes the row to selected, so how can I fix this?
In other words, I want that the button shows the selected rows the same way as it is shown in the select-info class in the end of the table (# rows selected)
Go to the last row
Hi,
I would like to know if its possible, when i make a modification or a new insert in my table without pagination, can scroll the line on the top of the table after this.
Regrads
href for only field name start with certain name
hi,
I want to make some column in my datatable "href " with a condition if that column name start with some thing like a word "week" or "day"
Regards
filter SQL query by where ID=$_Session(ID)
I need to get table data only related to session ID. That means show data specific to a logged user.
How can i do this with datatable?
filter SQL query by where ID=$_Session(ID).
When i put this to fetch.php file. it give error.
"processing":true,
"serverSide":true,
"order":[],
"ajax":{
url:"fetch.php",
type:"POST"
},
Possibility to handle upload errors.
I have 4 kinds of possible errors that are handled on the server:
- An unexpected error has occurred.
- Not correct file type (only JPEG, PNG and GIF images are allowed).
- Bad image format.
- Size to big.
If one of those errors happen I will send a JSON back to the client with fieldErrors like this:
{"fieldErrors":[{"name":"groups.image","status":"Max allowed size is 400kb."}]}
But then I have an unexpected issue.
Below 4 events. The only event being triggered is [uploadXhrSuccess].
editor.on(`submitUnsuccessful`, function(e, json)
{
console.log(`submitUnsuccessful`);
/* Only if the server reported fieldErrors we need to set our tabs in error color. */
if (json.hasOwnProperty(`fieldErrors`))
{
setTabErrors()
}
/* Other code below ..... */
});
/* Submit Error. */
editor.on(`submitError`, function(e, xhr, err, thrown, data)
{
console.log(`submitError`);
});
/* Upload Xhr Success. */
editor.on(`uploadXhrSuccess`, function (e, fieldName, json)
{
console.log(`uploadXhrSuccess`);
/* Only if we have fieldErrors we need to set or tabs in error color. */
if (json.hasOwnProperty(`fieldErrors`))
{
console.log(json.fieldErrors);
setTabErrors()
}
});
/* Upload Xhr Error. */
editor.on(`uploadXhrError`, function(e, fieldname, xhr)
{
console.log(`uploadXhrError`);
});
/* Show tabs in danger color if fields inside have errors. */
function setTabErrors()
{
console.log(`editor.field('groups.image').inError(): ` + editor.field(`groups.image`).inError());
/* Other code below ..... */
};
So I have put my code to check if some errors were found on the server side during the upload inside the [uploadXhrSuccess] event.
The label of my image-upload receives the error color, the error message is shown. But both edit.field(`groups.image`).inError()
and editor.inError()
return false.
I have read this forum post about this kind of issue:
https://datatables.net/forums/discussion/39090/upload-submiterror-events-not-triggered-for-upload
How to display Select Input default value?
Using serverSide: true, I set a default search on Column 1 with a val='false':
"searchCols": [
null,
{"search": 'false'},
null ]
This works ok and the initial filtered data is returned. However, initComplete (where the filters are setup) executes after the initial serverSide call. Column 1 filter definition in initComplete is:
api.columns([1]).every( function () {
var column = this;
var select = $('<select><option value=""></option></select>')
.appendTo( $(column.footer()).empty() )
.append( '<option value="true">Active</option>' )
.append( '<option value="false">Archived</option>' )
.on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex($(this).val());
column.search( val).draw(true);
} );
} );
The filter works correctly but the Select Input dropdown does not show the initial search value of 'Archived' (false). How do I get it to display the default search value?
I thought I should be able to do something like this in initComplete after the filter is created:
$('#users-table').DataTable().columns([1]).search('true');
without the Draw so as to not trigger another serverside call but this doesn't work.
Any ideas would be greatly appreciated. Thanks
Editor REST Example SharePoint 2010
Hi,
I'm trying to use the Editor to perform inline edits with SharePoint 2010. Weve used datatables for over 2 years and really like it and purchased the editor. Now, though, I'm not sure how to implement the editor. We really, at this time want to edit records.
I'm not even able to get the page to load the data to the table. Here is a copy of my code:
$(document).ready(function() {
editor = new $.fn.dataTable.Editor( {
ajax: {
edit: {
type: 'PUT',
url: '../php/rest/edit.php?id=_id_'
}
},
table: "#example6",
fields: [ {
label: "EmployeeDN:",
name: "EmployeeDN"
}
]
} );
$('#example6').DataTable( {
dom: "Bfrtip",
paging: false,
searching: false,
ajax: $.ajax({
'url': thisbase + "/_vti_bin/ListData.svc/List?$select=Id,EmployeeDN",
'headers': { 'Accept': 'application/json;odata=verbose' },
type: "GET",
dataType: "json",
success: function (data) {
var r = data.d.results;
var revised = new Array();
for(i = 0; i< r.length; i++){
var count = i+1;
var n = new Object();
n.DT_RowId = "row_"+count,
n.Id = r[i].Id;
n.EmployeeDN = r[i].EmployeeDN;
revised.push(n);
}
//console.log(JSON.stringify(revised));
return revised;
}
/*'dataSrc': function(data) {
return data.value.map(function(item) {
return [
//item.EmployeeDN
item.ID,
item.BusinessUnit,
item.Category,
item.Status,
new Date(item.DueDate),
item.AssignedTo.Title
];
});
}*/
}),
columns: [
{ data: "EmployeeDN" },
],
select: true,
buttons: [
{ extend: "edit", editor: editor }
]
} );
});
I used the console to pull the data returned:
[{"DT_RowId":"row_1","Id":320,"EmployeeDN":"XXX"},{"DT_RowId":"row_2","Id":347,"TripPriority":null,"EmployeeDN":"YYY"}]
Not quite sure where to go from here.
row.add not work
I have the following code:
success: function(msg) {
var dat = $.parseJSON(msg);
console.log(dat);
if(dat.msg == '1'){
table.row.add( [
dat.data.id_documento,
dat.data.identificador,
dat.data.nombre_documento,
dat.data.promotor,
dat.data.estado,
dat.data.accion
] ).draw( false );
console.log(dat.data.id_documento);
where console print value -> 19.
DataTables warning: table id=datatable - Requested unknown parameter 'id_documento' for row 18, column 0.
i have no idea why that warning.
How to get rid of Diagonal blue bars when using scroller?
Hello, I recently started using the scroller instead of pagination for my web app (which I really like).
My only problem is that any table that only has a few records (not one "page" worth of records), I get these blue diagonal bars shown under the rows. Is there any way to get rid of them or auto size the height of the table when I only have a small amount of records?
I use ajax data sourced from a server.
Load simple JSON data error
Hi
I am having trouble loading a simple JSON object
I try to load data of the following simple format
{
"id": 21,
"keyonename": "myfile.txt",
"keytwototal": 22,
"keythreelocation": 23
}
as follows (from file for testing)
function getSummData(cb_func1) {
$.ajax({
url: "data/summ.json",
success: cb_func1
});
console.log(cb_func1)
}
$(document).ready(function () {
getSummaryData(function (data1) {
//data = JSON.parse(data);
console.log(data1)
$('#summaryTable').DataTable({
data: data1 ,
"columns": [
{"data": "id"},
{"data": "keyonename"},
{"data": "keytwototal"},
{"data": "keythreelocation"},
]
});
});
});
however the table always prints no data available
. I have tried removing the data:data1
line but i get the same result.
If i modify the JSON to the following format
{
"summ":{ [ "id": 21,
"keyonename": "myfile.txt",
"keytwototal": 22,
"keythreelocation": 23
]}
}
and modify the data:data1
to data:data1.summ
it will work however i cannot control the server format and i am unable to do this in practice.
Any help much appreciated.
Validate::boolean does not appear to be working
We are currently working with Editor php version 1.6.5 and the built in boolean validation function is responding with 'Please enter true or false' when any false/0 value is submitted. I did a little digging into the code and line 365 of Editor/Validate.php has the following:
if ( filter_var($val, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) === false ) {
I believe filter_var is returning false for all false/0 values and null if the value is not valid. So I false should actually be replaced with null in this line.
if ( filter_var($val, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) === null ) {
Can someone confirm that this is the case. Thanks!
Error using FixedColumns with Row Grouping
Hello, I want to use the FixedColumns extension with the Row Grouping example
It seems to cause a conflict with the extension when I add those extra-rows.
Here it's an example that causes the same crash http://live.datatables.net/bujugimu/1/edit
My question is, there's a way I could make FixedColumns extension to ignore these rows?
column.search filtering on blank value
good day, i am using
column.search(val, true, false ).order( [[ 1, 'asc' ]] ).draw();
and in my column i have blank values and some strings. Could you recomend me how can i receive rows with blank values? Reason, when i send to value blank string, i am getting whole list, like unfiltered, but i wanna to have list where cells is blank... Do someone has ideas?