crud buttons not working
crud buttons not working
Hi Allan. It's "femolah" thanks for letting me know I created another account femolah for editor. it's been a while I've visited datatables.net.. :)
I have upgraged my editor 1.2.2 to 1.2.4
couple of questions,
1. as I mentioned to you before in our last conversation, create button is creating new record, but not closing automatically. edit button is not still working, it's not popping any edit screen out. delete button this time around is not popping out screen to give information decision to delete. I guess there is problem with the ajax..
I have tested my ajaxUrl, it's working fine, loading the records. I have given id to the tr for my DOM source table
secondly, can printing (pdf, excel..) and crud work together under the tabletools function? it seems like I have to forgo one inorder to activate the other..
here is my code:
js and css:
js for editor and datatable:
$(document).ready(function() {
// UK Date Sorting
jQuery.fn.dataTableExt.oSort['uk_date-asc'] = function(a, b) {
var ukDatea = a.split('/');
var ukDateb = b.split('/');
var x = (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
var y = (ukDateb[2] + ukDateb[1] + ukDateb[0]) * 1;
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['uk_date-desc'] = function(a, b) {
var ukDatea = a.split('/');
var ukDateb = b.split('/');
var x = (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
var y = (ukDateb[2] + ukDateb[1] + ukDateb[0]) * 1;
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
/*Sorting code from DataTables*/
//sorting tables currency
jQuery.fn.dataTableExt.aTypes.push(
function ( sData )
{
var sValidChars = "0123456789.-,";
var Char;
/* Check the numeric part */
for ( i=1 ; i
I have upgraged my editor 1.2.2 to 1.2.4
couple of questions,
1. as I mentioned to you before in our last conversation, create button is creating new record, but not closing automatically. edit button is not still working, it's not popping any edit screen out. delete button this time around is not popping out screen to give information decision to delete. I guess there is problem with the ajax..
I have tested my ajaxUrl, it's working fine, loading the records. I have given id to the tr for my DOM source table
secondly, can printing (pdf, excel..) and crud work together under the tabletools function? it seems like I have to forgo one inorder to activate the other..
here is my code:
js and css:
js for editor and datatable:
$(document).ready(function() {
// UK Date Sorting
jQuery.fn.dataTableExt.oSort['uk_date-asc'] = function(a, b) {
var ukDatea = a.split('/');
var ukDateb = b.split('/');
var x = (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
var y = (ukDateb[2] + ukDateb[1] + ukDateb[0]) * 1;
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['uk_date-desc'] = function(a, b) {
var ukDatea = a.split('/');
var ukDateb = b.split('/');
var x = (ukDatea[2] + ukDatea[1] + ukDatea[0]) * 1;
var y = (ukDateb[2] + ukDateb[1] + ukDateb[0]) * 1;
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
/*Sorting code from DataTables*/
//sorting tables currency
jQuery.fn.dataTableExt.aTypes.push(
function ( sData )
{
var sValidChars = "0123456789.-,";
var Char;
/* Check the numeric part */
for ( i=1 ; i
This discussion has been closed.
Replies
<?php
/*
* Example PHP implementation used for the htmlTable.php example where
* the information from the table is returned as an array (indexes) rather
* than as JSON object properties, since the table is read from the DOM as
* an array.
*/
// DataTables PHP library
include( "lib/DataTables.php" );
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Join,
DataTables\Editor\Validate;
// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'costs_for_all_expenditure_categories' )
->fields(
Field::inst( 'expenditure_category_id', 0 ),
Field::inst( 'category_table_id', 1 ),
Field::inst( 'costs_for_all_expenditure_categories', 2 ),
Field::inst( 'costs_for_all_expenditure_categories_date_entered', 3 ),
Field::inst( 'costs_for_all_expenditure_categories_comments', 4 )
)
->process( $_POST )
->json();
Expenditure Category id
Direct Debit Expenditures
Cost
Date
of Entry
Comments
<?php do { ?>
<?php echo $row_listing_of_all_cost_entries_by_categories_query['expenditure_category_id']; ?>
<?php echo $row_listing_of_all_cost_entries_by_categories_query['category_table_id']; ?>
£<?php echo $row_listing_of_all_cost_entries_by_categories_query['cost_figures']; ?>
<?php echo $row_listing_of_all_cost_entries_by_categories_query['costs_for_all_expenditure_categories_date_entered']; ?>
<?php echo $row_listing_of_all_cost_entries_by_categories_query['costs_for_all_expenditure_categories_comments']; ?>
<?php } while ($row_listing_of_all_cost_entries_by_categories_query = mysql_fetch_assoc($listing_of_all_cost_entries_by_categories_query)); ?>
Expenditure Category id
Direct Debit Expenditures
Cost
Date Entered
Comments
Yes, simply add the export options you want to the aButtons array of TableTools. For example:
[code]
"aButtons": [
{ "sExtends": "editor_create", "editor": editor },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor },
'csv',
'print'
]
[/code]
Regarding the error you are having with the editing abilities. Can you link me to the page please? I don't immediately see a problem with the code you posted, so I'd need to see a test case in order to understand what is going wrong.
Allan
I'm on localhost unfortunately, will copying and pasting full source code be of help?
Let's deal with the 'add' first. When you create a new record and hit the 'Save' button, what does the server reply with for the Ajax request? Specifically, what does the script `Editor/examples/php/json_direct_debits_edit.php` send back? I'm going to guess a JSON error, but I'm not sure!
Thanks,
Allan
{"id":-1,"fieldErrors":[],"sError":"","aaData":[{"DT_RowId":"row_1","0":"1","1":"1","2":"50.0000","3":"2013-01-01","4":"January council tax"},{"DT_RowId":"row_2","0":"1","1":"1","2":"50.0000","3":"2013-02-01","4":"February council tax bill"},{"DT_RowId":"row_3","0":"1","1":"1","2":"50.0000","3":"2013-03-01","4":"March council tax bill"},{"DT_RowId":"row_4","0":"1","1":"1","2":"50.0000","3":"2013-04-01","4":"April council tax bill"},{"DT_RowId":"row_5","0":"1","1":"1","2":"50.0000","3":"2013-05-01","4":"May council tax bill"},{"DT_RowId":"row_6","0":"1","1":"1","2":"50.0000","3":"2013-06-01","4":"June council tax bill"},{"DT_RowId":"row_7","0":"1","1":"1","2":"50.0000","3":"2013-07-01","4":"July council tax bill"},{"DT_RowId":"row_8","0":"1","1":"1","2":"50.0000","3":"2013-08-01","4":"August council tax bill"},{"DT_RowId":"row_9","0":"1","1":"1","2":"50.0000","3":"2013-09-01","4":"september council tax bill"},{"DT_RowId":"row_10","0":"1","1":"1","2":"50.0000","3":"2013-10-01","4":"october council tax bill"},
no error Allan.
when I hit the save button, the circular flash keeps on rolling and not stopping, no error displayed. I have to close the modal screen myself and when I refresh the table, the record has been added to the table. my error reporting in the config is reporting all.
Allan
how do I check for the 'create' ajax request? sorry newby..
Emmanuel.
how do I check for the 'create' ajax request? sorry newby..
Emmanuel.
We are interested in the Ajax request made after the Create / Save button has been pressed.
Allan
JQMIGRATE: Logging is active jQuery_Migrate-v1.2.js:22
JQMIGRATE: jQuery.fn.live() is deprecated jQuery_Migrate-v1.2.js:42
console.trace() jQuery_Migrate-v1.2.js:44
migrateWarn jQuery_Migrate-v1.2.js:44
event.returnValue is deprecated. Please use the standard event.preventDefault() instead.
Uncaught TypeError: Cannot read property 'oFeatures' of null
when I reloaded, this is what the debugger said when I clicked create button:
in file jquery.js:
Warning:
event.returnValue is deprecated. Please use the standard event.preventDefault() instead.
in datatables.editor.js:
error:
Uncaught TypeError: Cannot read property 'oFeatures' of null
BUT when I click the create, the same error still comes up: Uncaught TypeError: Cannot read property 'oFeatures' of null
no warnings. (I left the aLengthMenu the default in the jquery.datatables.js and got rid of the warning: event.returnValue is deprecated. Please use the standard event.preventDefault() instead. )
> Uncaught TypeError: Cannot read property 'oFeatures' of null
That's a bit more working. I'm afraid, off the top of my head, I don't know what would cause that error. Is there any way you can put your files up on a web-server somewhere that I can access? Or possibly zipping them up and e-mailing them over (although if you could put it on a site somewhere, that would be fantastic, since the database you are using would be in place).
Thanks,
Allan
I tried using the 1.2.2 version, still gives the same problem but with the popping out of delete modal screen which is not popping out with version 1.2.4
with version 1.2.4,
when I click the delete button, the full error details from chrome tool is:
Uncaught TypeError: Cannot read property 'aoData' of null jquery.dataTables.js:4979
$ jquery.dataTables.js:4979
_ jquery.dataTables.js:5119
Editor.remove dataTables.editor.js:2054
ttButtons.editor_remove.$.extend.fnClick dataTables.editor.js:3905
(anonymous function) TableTools.js:1263
p.event.dispatch jquery.js:2
g.handle.h jquery.js:2
when I click the edit button, the full error details from chrome tool is:
Uncaught TypeError: Cannot read property 'aoData' of null jquery.dataTables.js:4979
$ jquery.dataTables.js:4979
_ jquery.dataTables.js:5119
Editor._rowId dataTables.editor.js:2929
Editor.edit dataTables.editor.js:1509
ttButtons.editor_edit.$.extend.fnClick dataTables.editor.js:3866
(anonymous function) TableTools.js:1263
p.event.dispatch jquery.js:2
g.handle.h jquery.js:2
full error details when I click the create button is:
Uncaught TypeError: Cannot read property 'oFeatures' of null dataTables.editor.js:2849
(anonymous function) dataTables.editor.js:2849
$.ajax.success dataTables.editor.js:3153
k jquery.js:2
l.fireWith jquery.js:2
y jquery.js:2
d jquery.js:2
thanks.
Allan
I extracted this page from the main project.
I will email you zip file as well.
thanks.
> "domTable": "direct_debits_table_id",
Should be:
> "domTable": "#direct_debits_table_id",
Its basically a jQuery selector, so at the moment it was looking for a node called `direct_debits_table_id` which is of course couldn't find. Adding a `#` makes it an ID selector.
Allan
that's true. many thanks. I've tested it, it's working now.
I really want to appreciate and thank you for your time and helping me out on this.
thanks thanks thanks thanks. :)
Kind Regards,
Emmanuel.
Allan