How can I enable the newline when editing data in a textarea field type
Cannot enter a new line with a textarea field type
Editing in Related Tables
I'm trying to port an existing web app into DataTables/Editor. Any record in the table being edited might have zero to many related records in another table. Is there any way from within an Editor form to invoke the editor again on the related table record in the related table? I'd like to be able to create a record in the related table when necessary, as well as to display the related records in that table. So far, I haven't found a way to do this within the DataTables/Editor framework.
Since this is a feasibility question, I don't have a problem pagers debug or link to. However, I can provide more detailed information if that would help someone who wants to respond.
Data table working on localhost but not online server
I am using server side datatables.
I am able to run my script on localhost successfully but online it's not working.
My server side function
function addevents()
{
$table = 'mov_wsmovies_events';
$primaryKey = 'id';
$columns = array(
array( 'db' => 'title', 'dt' => 'title' ),
array( 'db' => 'profile_image', 'dt' => 'profile_image',
'formatter' => function( $d, $row ) {
//$src = $base.'/'.$d;
$src = JURI::root().$d;
return "<img src='$src' width='50px' height='50px'>
";
}
),
array( 'db' => 'cover_image', 'dt' => 'cover_image',
'formatter' => function( $d, $row ) {
$src = JURI::root().$d;
return "<img src='$src' width='60px' height='40px'>
";
}
),
array(
'db' => 'id',
'dt' => 'action',
'formatter' => function( $d, $row ) {
return "<a href='#' onclick='funedit($d)'><i class='fa fa-pencil-square-o' aria-hidden='true'></i></a> <a href='#' onclick='fundelete($d)'><i class='fa fa-trash' aria-hidden='true'></i></a> <a href='index.php?option=com_wsmovies&Itemid=604&view=addevents&model=addevents&layout=manage_pricings&eventId=".$d."'><label class='label label-primary'>Manage pricings</label></a>
";
}
)
);
$sql_details = $this->db_details();
$where = "id =1";
$user = JFactory::getUser();
$user_id = $user->id;
$res = DatatableHelper::complex( $_GET, $sql_details, $table, $primaryKey, $columns, null,"user_id = $user_id" );
echo json_encode($res);
die;
}
My client side function
var eventTable;
$(document).ready(function() {
eventTable = $('#example').DataTable( {
"processing": true,
"serverSide": true,
"ajax": "<?php echo JRoute::_('index.php?option=com_wsmovies&task=addevents' ); ?>",
"columns": [
{ "data": "title" },
{ "data": "profile_image" },
{ "data": "cover_image" },
{ "data": "action" },
],
} );
$('#example_length select').css("display", "inline");
$('#example_filter input').css("display", "inline");
} );
Please somebody help me to solve this issue.
Common Settings for Multiple DataTables
Hi,
I am having multiple default settings for various pages. I wanted to have common functions which can be called on tables.
'''
$.extend( true, $.fn.dataTable.defaults, {
"searching"String: false,
"ordering"String: false
} );
$(document).ready(function() {
$('#example'String).DataTable();
} );
'''
Is it possible pass String or call function when you say
$('#example'String).DataTable(call function/string );
Thanks in advance
Join table example
I'm trying to display data from linked tables. As an exercise, I tried to recreate the example on this page: https://editor.datatables.net/examples/simple/join.html
This is my result: http://live.datatables.net/zatojowu/3/edit
DataTables insists that there is no data to display. I don't know what I'm doing wrong. Please send help.
Column cache is not returning values
Hi guy's,
I'm doing a big filtering system for the datatables, on which it consists on having multiple box's in each column, and in each box, there is a list of checkbox that come from the cache('search') and a multi filter system of multiple options between two selects and two inputs.
After battling with this, and almost finishing it, it came an strange issue. The cache function doesnt return any info on the data that is appearing on the table - it did yesterday. I already rollbacked alot of code and nothing.
This is the code I'm using...
table.columns().flatten().each(function (colIdx) {
table.column(colIdx).cache('search').sort().unique().each(function (d) {
console.log("inside")
});
});
As you can probably guess, it should run the message in the console, but nothing. Even when getting the data directly from the cache, It doesn't bring anything.
Did this happened to anyone?
Thank you!
Button Collection and bootstrap
I am a little helpless. I have a button group inserted as in your export buttons example. The export button is displayed correctly, but the dropdown field does not look the same as in the example. Only the name is displayed and the corresponding icon. The button design is totally missing. I have added the class btn and btn-default. Now I have a frame, but the distances do not fit and all buttons are displayed in a row. The comparison with your example and the one on my site shows a big difference. The buttons in the example are designed with div and in my Page with ul tag. Normally I should be able to adjust everything with css, but here I do not know where to start. I tried something, but then the table looks strange. The design did not fit at all.
You can see it via the link I sent you.
Andreas
Multi filtering system problem
Hi guy's,
I've created an "extension" to the datatables to project my needs.
It basically consists on a box with many types of filters. Multi checkbox's that are added to a regex string for search purposes, many types of calculations depending on the type of data to check if it's null, bigger than etc to add the result to the regex string and the possibility of having an external filtering data coming from multiple charts. Basicly I'm getting the current data saved at the local storage and editing the search string's from the correct columns.
All this seems pretty "doable", except a problem I'm having.
When loading the chart from the local storage - as explained in the manual from here - it comes everything correct but I can't access in any way to the cache from the search, so that I can create the filtering system.
From what I've understood, when doing:
table.column(table.colReorder.transpose(colIdx)).cache('search').unique().sort().each(function (d) {
The unique() and sort() would "emulate" a change to the datatable, so there should always be cache at the search.
Isn't this the main purpose, like it's explained on the manual?
Thank you all.
Excel button defaulting to flash instead of HTML5
I just upgraded to using dataTables 1.10.13 and when using "buttons": [ 'copy', 'excel', 'csv' ]
for some reason copy
and csv
buttons default to HTML5 like they are supposed to however the excel
button defaults to flash. Any ideas on what would cause just the one button to not default to the proper type?
Why does datatable css break for last column when page length over 100?
I am using multiple datatables in my project. For only one table, when I use a page length of 250 or 500, the last column loses its datatable styling. It still shows up and has the right data, just falls outside the border of the table now. GO back to a lower page length and everything is normal again.
How to set data from jsonresponse
When user clicks report button on my page , it starts to run my service and return jsonresponse , and I want to set this response to datatable ? All How can I do? Please help
My Class
public class DosyaMasrafList
{
public String Dosya_No;
public String Fatura_Tarihi;
public String Ithal_Ulke;
}
My Service
[WebMethod]
public JsonResponse<List<DosyaMasrafList>> DosyaMaliyetRapor(string Tarih1,string Tarih2)
{
JsonResponse<List<DosyaMasrafList>> response = new JsonResponse<List<DosyaMasrafList>>()
{
Data = new List<DosyaMasrafList>(),
Success = true,
Message = ""
};
response.Data = DosyaMasrafDB.DosyaMaliyetRapor(Tarih1, Tarih2);
return response;
}
My page
</div>
<div class="portlet-content">
<div class="table-responsive">
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Dosya No</th>
<th>Fatura Tarihi</th>
<th>İthal Ülke</th>
</tr>
</thead>
</table>
<div id="Container">
</div>
</div>
My jscript
loadDosyaMaliyetRapor= function () {
axaAjax({
url: "../Services/ZeusRepWeb.asmx/DosyaMaliyetRapor",
data: JSON.stringify({
Tarih1: $("#Tarih1").val(),
Tarih2: $("#Tarih2").val()
}),
success: function (msg) {
if (msg.d.Success) {
var a = {
d: msg.d.Data
}
var table = $('#example').DataTable(); ?????? how to use
}
}
});
},
Select A Row of Known DT_RowId
Please, after loading the table, I wish to select a row of known DT_RowId. How to implement this?
OT: But, please add filter to the web-site searches, so that we could filter say forum entries from sample entries.
Excel-Like Keyboard Navigation In Mozilla Firefox
We are struggling to get the excel-like keyboard navigation to work in Mozilla Firefox(50.1.0 for example). We notice that the example page for this feature doesn't even appear to work in Mozilla Firefox.
The below link illustrates the feature and it works well in IE/Chrome but we are unable to get this feature to work in Mozilla Firefox. Does this feature support that browser? Do you have any suggestions?
https://editor.datatables.net/examples/extensions/keyTable.html
Thanks,
Brent
How to reset date in .set
Hi ,
$('#packageaccounttable').on( 'click','#setrowempty', function (e) {
editor
.edit( $(this).closest('tr'), false )
.set ('particular','')
.set ('purchase_amt',0)
.set ('sale_amt',0)
.set ('remarks','')
.set ('vendor','')
.set ('booking_date','0')
.set ('payment_date','0')
.set ('payment_mode','')
.set ('booking_id','')
.set ('payment_made','')
.set ('voucher_issued','N')
.submit();
} );
in above example every columns is initializing except booking_date and payment_date.
after sumit shows 01-01-1970
should be 00-00-0000
How to do this.
Regards.
Sunil
how do you add two or more styles on button export?
I am currently trying to add a header that is centered and has a grey background.
$('table.data-table').DataTable({
dom: 'Bfrtip',
buttons: [
{
extend: 'excel',
text: 'Save as Excel',
customize: function( xlsx ) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
$('row:first c', sheet).attr( 's', '42');
},
}
]
Count only visible columns
Hello,
is it possible to count only visible columns?
With
table.columns().header().length;
counts all columns also the hidden.
Thx for response!
Column width option not being applied
I'm trying to apply a column width to each column, but it is not being reflected in the output:
http://live.datatables.net/mekuxeya/1/edit?js,output
I've tried setting autoWidth to both true and false, but it does not seem to have any effect. Bootstrap styling, scrollX, and scrollY are also being applied.
Manually Delete multiple records by filtering rows
hi i really need this so badly. I'm trying to remove multiple rows which contains specific string but i fail.
Here's an example what im trying to do:
..
if (table.rows().data().[contains] SomeString)
[deleteThatRow]?
Or
table.rows().every(function (){
if this.data().[Contains] somestring [DeleteIt]?
});
Datatables within a bootstrap 3 tab
I have a page with three bootstrap tabs. Only the second tab includes a datatable. However, when I click to show the tab the datatable isn't redrawing so columns are squished and the table only takes up part of the page. I've followed docs at https://datatables.net/examples/api/tabs_and_scrolling.html to tell the datatable to recalc but nothing happens. Datatables version is 1.10.12. Any help is appreciated!
<html>
<head>
<link media="all" type="text/css" rel="stylesheet" href="dataTables.bootstrap.min.css">
</head>
<body>
<!-- ... -->
<div role="tabpanel" class="tab-pane mt-30 active" id="participants">
<div class="box-body">
<div class="table-responsive">
<table id="participants-table" class="table table-condensed table-hover">
<thead>
<tr>
<th>Org ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email</th>
<th>Group</th>
<th>Referral Code</th>
<th>Actions</th>
</tr>
</thead>
</table>
</div><!--table-responsive-->
</div><!-- /.box-body -->
</div><!--tab participants-->
<!-- ... -->
<script src="jquery.js"></script>
<script src="jquery.dataTables.min.js"></script>
<script src="dataTables.bootstrap.min.js"></script>
<script>
$(document).ready(function() {
$('a[data-toggle="tab"]').on( 'shown.bs.tab', function (e) {
if(e.currentTarget.hash == '#participants') {
$('.tab-content > #participants').show();
$.fn.dataTable.tables( {visible: true, api: true} ).columns.adjust();
} else {
$('.tab-content > #participants').hide();
}
} );
$('#participants-table').DataTable({
processing: true,
serverSide: true,
ajax: {
url: 'participant/get',
type: 'post'
},
columns: [
{data: 'org_internal_id', name: 'participants.org_internal_id'},
{data: 'first_name', name: 'participants.first_name', render: $.fn.dataTable.render.text()},
{data: 'last_name', name: 'participants.last_name', render: $.fn.dataTable.render.text()},
{data: 'email', name: 'participants.email', render: $.fn.dataTable.render.text()},
{data: 'org_group', name: 'participants.org_group', searchable: false, render: $.fn.dataTable.render.text()},
{data: 'referral_code', name: 'participants.referral_code', sortable: false, render: $.fn.dataTable.render.text()},
{data: 'actions', name: 'actions', searchable: false, sortable: false}
],
order: [[0, "asc"]],
searchDelay: 500
});
});
</script>
</body>
</html>
Restart pagination without calling draw() (server side)
Hi,
I have a server-side DataTable. I would like to avoid calling draw() just to reset the pagination when the data changes (calling draw() means that ajax will be executed twice). So I decided to check if pagination reset is needed (meaning the user does a new search and new data should be displayed) and destroy the DataTable and recreate it passing d.start = 0 to data in the ajax call. But the pagination is still off. It will show for instance:
Showing 4,271 to 6 of 6 entries
if the user was at 4271st record in the previous search, even though we have only 6 records to display.
The reason for that behaviour seems to be DataTables localStorage which keeps start: 4270 for that page. Is there any way to override localStorage start value without calling draw() and without tweaking localStorage manually, of course?
I hope I'm making myself clear, let me know if you need more info.
Many thanks (and many thanks for a great library),
Marta