I want to ask how to take the value of the variable id from Ajax datatables and show value in PHP or HTML? For example: I datatables ajax and everything works without problem using JS file. But I just want to take the value of the JS file in HTML or PHP? It is possible and ask for help.
Echo variable from JS to HTML / PHP
Implementing example and faced with: Error: [$injector:unpr] - please help with error? NG 1.3.x
My code in my controller is:
angular
.module('app.cms')
.controller('CmsCtrl', CmsCtrl);
CmsCtrl.$inject = ['$scope', '$location', '$rootScope', '$route', '$resource', '$document', 'UserDataService', 'localStorageService', 'ezfb', 'datatables'];
function CmsCtrl($scope, $location, $rootScope, $route, $resource, $document, UserDataService, localStorageService, ezfb, DTOptionsBuilder, DTColumnBuilder) {
The error is:
Error: [$injector:unpr] http://errors.angularjs.org/1.3.16/$injector/unpr?p0=datatablesProvider%20%3C-NaNatatables%20%3C-%20CmsCtrl
Things I have tried are:
-Verified repeatedly that js file is properly included.
-Since this is a module on a bigger app, I did try moving the 'datatables' into the main app module for injection. This works to remove the unpr error, but that is then replaced with an error for newOption being attached to an undefined object.
Target column with class name not working as expected
I have a datatable working with an ASP.NET GridView perfectly. For some reason I have to define a specific column that include checkboxes. When I define it using the index it works fine but I need to make it more flexible with defining it using a class name where it actually work fine but generate error (mdata not defined) when delete all rows while not if this column defined using index.
This works fine:
"columnDefs": [
{ "targets": 0, "bSortable": true },
{ "targets": 2, "bSortable": true },
{ "targets": 3, "bSortable": true },
{ "targets": 5, "bSortable": true },
{ "targets": 8, "bSortable": false }, // checkboxes column
{ "targets": '_all', "bSortable": false }
],
This is not working the same:
"columnDefs": [
{ "targets": 0, "bSortable": true },
{ "targets": 2, "bSortable": true },
{ "targets": 3, "bSortable": true },
{ "targets": 5, "bSortable": true },
{ "targets": 'chkAll', "bSortable": false }, // checkboxes column
{ "targets": '_all', "bSortable": false }
],
I've also tried
"columnDefs": [
{ "targets": 0, "bSortable": true },
{ "targets": 2, "bSortable": true },
{ "targets": 3, "bSortable": true },
{ "targets": 5, "bSortable": true }
],
"aoColumnDefs": [
{
"bSortable": true,
"aTargets": [ -1 ] // checkboxes column
}
],
I also tried to not define that column since I do't need to but actually the error only disappear when defining it. Any idea why it's not effected when select all checkboxes and delete rows in second case?
Note: I use GridView, UpdatePanel and all works fine in all events.
Thank you,
server side pagination
I see this required class from the server side script
require( 'ssp.class.php' );
echo json_encode(
SSP::simple( $_GET, $sql_details, $table, $primaryKey, $columns )
);
This cus me errors when i want to use this example
https://datatables.net/examples/data_sources/server_side.html
Please help meout
When creating child rows, my implementation refuses to show them.
Hello all,
I'm trying to add a details view to my table, however even though my functions get called correctly in the console, it never outputs a child object. Any insight would be greatly appreciated.
<script type="text/javascript">
var table;
function format(s){
console.log('format function successfully called');
return s;
}
$(document).ready(function(){
table = $('#GOAT').DataTable({
"columnDefs":[
{"orderable": false, "targets":1}
]
});
$('#GOAT tbody').on('click', 'tr', function () {
// var data = table.row(this).data();
// console.log('You clicked on the '+data[2]+' row');
var tr = $(this).closest('tr');
// alert(tr.id);
var row = table.row( tr );
// alert(row.id);
if (row.child.isShown() ) {
// This row is already open - close it
console.log("closing child");
row.child.hide();
tr.removeClass('shown');
}
else {
console.log("opening child");
row.child(["this is a test string","another test string"]).show();
row.child("this is a test string").show();
row.child(format(row.data())).show();
row.child.show();
tr.addClass('shown');
}
} );
});
Select field type
Hello. I'm using the latest versions of Datatables and Editor. I am using inline editing and have a Select field type that allows multiple selections. How do I get it to pre-select the already selected items when it drops down for edit?
Additionally, there are hundreds of values in this select list. I need to allow it to be filtered. What is the recommended way of adding a filter to the top of a Select editor?
Thanks,
Matt
Set focus on filter input
As discussed at: https://datatables.net/forums/discussion/6401/change-the-word-search-to-filter -- perhaps needs to be updated. Out of the box my filter input's markup looks like
<div id="ordersTable_filter" class="dataTables_filter">
<label>
Search:
<input class="" type="search" placeholder="" aria-controls="ordersTable">
</label>
</div>
I've tried both:
$('#ordersTable_filter input:search').focus(); // tosses error
and:
$('#ordersTable_filter input:text').focus(); // doesn't work
Getting value of selected rows
I've been reading the post but still haven't gotten any of the following to work. Any suggestions are greatly appreciated. When I do this, which on found in forums I get live is not a function.
$("#example tbody tr").live("click", function(event){
var id = myTable.fnGetData(this)[0];
displayUserInfo(UnitIdd);
});
When I did this, it worked until I added the next 2 lines. Then it didn't run the function looks like as soon as I add the tr it doesn't hit the function.
$('#example tbody ').click(function (e) {
alert('test');
});
$('#example tbody tr').click(function (e) {
var id = myTable.fnGetData(this)[0];
displayUserInfo(UnitId);
alert('test');
});
Here is the table setup
Unit ID | Unit Type | UnitTypeDesc | SqFtg | Bedrooms | Bathrooms | Market Rent | Floor Plan |
---|
trouble with parsing array of obj from remote server (json)
Thank you guys in advance for any help you might be able to provide me here.
I am getting this error:
jquery.dataTables.min.js:39 Uncaught TypeError: Cannot read property 'length' of undefined
Here's my markup:
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>ID</th>
<th>Activity</th>
<th>Start</th>
<th>End</th>
<th>Description</th>
</tr>
</thead>
</table>
Here's my API call:
$('#example').DataTable( {
"processing": true,
"serverSide": true,
"ajax": {
"url": "//breaktime.imrapid.io/get_activities",
"dataType": "json"
},
"aoColumns": [
{ "mData": "_id" },
{ "mData": "activity" },
{ "mData": "start" },
{ "mData": "end" },
{ "mData": "description" }
]
} );
Here's the network response: (validated as good json!)
200 OK
[{"_id":"56edd040c085311a00dfdf77","activity":"testing new","start":"03-22-2016","end":"03-22-2016","description":"<p>testing description</p>"},{"_id":"56edd0413625401a00b23a7b","activity":"testing new","start":"03-22-2016","end":"03-22-2016","description":"<p>testing description</p>"},{"_id":"56edd0423625401a00b23a7d","activity":"testing new","start":"03-22-2016","end":"03-22-2016","description":"<p>testing description</p>"},{"_id":"56edd046c085311a00dfdf79","activity":"testing new","start":"03-22-2016","end":"03-22-2016","description":"<p>testing description</p>"}]
I am probably missing something trivial. Can anybody spot the problem? Thank you!
File Upload (Cordova Wrap application)
Hi Guys,
has anyone from you were able to wrap datatables using apache cordova?, using cordova SIM the the error has something to do with FileReader.js
limit and order
hello im use php class Editor
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'messages', 'id' )
->fields(
Field::inst( 'user_id' ),
Field::inst( 'cust_id' ),
Field::inst( 'status' ),
Field::inst( 'name_id' ),
Field::inst( 'subname_id' ),
Field::inst( 'message' ),
Field::inst( 'min' ),
Field::inst( 'max' ),
Field::inst( 'cur' ),
Field::inst( 'event_time' ),
Field::inst( 'sms_send' ),
Field::inst( 'email_send' )
)
// ->order( 'id DESC' )
->where( 'user_id', $_SESSION['uid'], '=' )
->process( $_POST )
->json();
if i use // ->order( 'id DESC' ) return error
if use limit return error
php class not have method limit and order ?
Merging JavaScript commands
This is my current JavaScript:
<script>
$(function () {
$("#speakers").DataTable({
"order": [[0, "desc"]]
});
$("#cfp").DataTable({
"order": [[0, "desc"]]
});
});
</script>
What I'd like is for both of these tables to display 100 records. I understand for this to work I need pageLength, so, like this:
$('#speakers').dataTable( {
"pageLength": 100
} );
I've tried merging these together but they don't work well - any idea how to make them work together? Thanks
Undefined index: sEcho in
Is any one there to solve this?
I am using mysqli.
Notice: Undefined index: sEcho in C:\xampp\htdocs\stylishbabu\admin\datatable\category_datatable.php on line 155
{"sEcho":0,"iTotalRecords":"12","iTotalDisplayRecords":"12","aaData":[["2","first"],["3","second"],["4","third"],["5","check"],["6","teststest"],["7","uytutyuty"],["8","qweqweqw"],["9","testtetest"],["10","poiuyy"],["11","bvcbdfgdfg"],["12","last"],["13","tesing today"]]}
Duplicate - click from href link
I know about Duplicate button, but I want not have button but I want duplicate for click to href link as link to Create New Record - https://editor.datatables.net/examples/simple/inTableControls.html inTableControls I want source code for Duplicate.
Thank you
Events - unsaved changes close confirmation with block used keyboard ESC
I want source code:
If I open Create new record and write to values and I clicked to keyboard keypress ESC, will not close !!!
Thank you.
desperately trying to render footer
I cant fnd a way or debug why footer is not rendered. Possible cases, or issues?
Update one column of all rows in dataTables
Hello everyone,
I have a discount column, i add an input for the % of the discount of the value and i want to refresh the whole column called "discount" when i put some % in the input... Is there anyway to do it, only in the client side?
I just need to calculate the new price, edit the data of that column (i don't know how) and redraw.
This is posible? i need al the help you can give me, i'm stuck here :(
Regards
Jquery to add/create form with one - many data.
HI Friends,
I am new to this JQUERY world, and I am trying to build a project where I need to add data with one to many relation.
for example:
Primary table :
table_id integer
customize_tag varchar(50)
account_id integerSeconary table
account_id integer
Account name VARCHAR(50)
Account Manager VARCHAR(50)
Account leverage double
I am planning to show the main screen as:
Customize_ tag Account names selected seperated by commas.
On Clicking the New Button, I want to accept
Customize_tag &
Show a grid with "Account name, Account manager and Account Leverage" and with multi selection or checkbox with multi selection option
So in one Create form, user should be able to select multiple account for a single customize tag. Same applies fo Edit.
Kindly advise, if this is doable, if not, what are the other option you would suggest
if yes, how ?
Thx
Prabhu
With Buttons - Column visibility button highlighting bug
Hi,
It looks like the css classes may be broken.
When you reduce the browser size so some columns are hidden, refresh the page, all columns in the button get the active class even though they are hidden.
The column name highlighting works fine after clicking on them but the initial state should not be active for the ones which are hidden
Could you please fix this
Thanks
https://datatables.net/extensions/responsive/examples/column-control/column-visibility.html
Problem for two fieldtypes
I try for create two fieldtypes for 2 variables:
Examples - https://editor.datatables.net/examples/simple/fieldTypes.html
There is one fieldtype - To do or Done.
But I want to create two fieldtypes, how?
Source code - it does not WORK :(
Please you help :-)
(function ($, DataTable) {
if (!DataTable.ext.editorFields) {
DataTable.ext.editorFields = {};
}
var Editor = DataTable.Editor;
var _fieldTypes_1 = DataTable.ext.editorFields;
_fieldTypes_1.variable1 = {
create: function (conf) {
var that = this;
conf._enabled = true;
conf._input = $(
'<div id="'+Editor.safeId( conf.id )+'">'+
'<button class="inputButton" value="1">YES</button>'+
'<button class="inputButton" value="0">NO</button>'+
'</div>');
$('button.inputButton', conf._input).click( function () {
if (conf._enabled) {
that.set(conf.name, $(this).attr('value'));
}
return false;
});
return conf._input;
},
get: function (conf) {
return $('button.selected', conf._input).attr('value');
},
set: function (conf, val) {
$('button.selected', conf._input).removeClass('selected');
$('button.inputButton[value='+val+']', conf._input).addClass('selected');
},
enable: function (conf) {
conf._enabled = true;
$(conf._input).removeClass('disabled');
},
disable: function (conf) {
conf._enabled = false;
$(conf._input).addClass('disabled');
}
};
})
(jQuery, jQuery.fn.dataTable);
(function ($, DataTable) {
if (!DataTable.ext.editorFields) {
DataTable.ext.editorFields = {};
}
var Editor = DataTable.Editor;
var _fieldTypes_2= DataTable.ext.editorFields;
_fieldTypes_2.variable2 = {
create: function (conf) {
var that = this;
conf._enabled = true;
conf._input = $(
'<div id="'+Editor.safeId( conf.id )+'">'+
'<button class="inputButton" value="1">INSTALL</button>'+
'<button class="inputButton" value="0">NO INSTALL</button>'+
'</div>');
$('button.inputButton', conf._input).click( function () {
if (conf._enabled) {
that.set(conf.name, $(this).attr('value'));
}
return false;
});
return conf._input;
},
get: function (conf) {
return $('button.selected', conf._input).attr('value');
},
set: function (conf, val) {
$('button.selected', conf._input).removeClass('selected');
$('button.inputButton[value='+val+']', conf._input).addClass('selected');
},
enable: function (conf) {
conf._enabled = true;
$(conf._input).removeClass('disabled');
},
disable: function (conf) {
conf._enabled = false;
$(conf._input).addClass('disabled');
}
};
})
(jQuery, jQuery.fn.dataTable);