crud buttons not working

crud buttons not working

femolahfemolah Posts: 23Questions: 0Answers: 0
edited January 2014 in Editor
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

Replies

  • femolahfemolah Posts: 23Questions: 0Answers: 0
    this is my ajaxUrl code:
    <?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();
  • femolahfemolah Posts: 23Questions: 0Answers: 0
    this is my DOM table data source:



    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
  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    > 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..

    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
  • femolahfemolah Posts: 23Questions: 0Answers: 0
    thanks for the quick reply. I really appreciate it. both the printing(pdf, excel..) and the crud buttons are showing up now. thanks.

    I'm on localhost unfortunately, will copying and pasting full source code be of help?
  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    To be honest, possibly not - but thanks for the e-mail with it. I'll keep it for reference as it might be useful.

    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
  • femolahfemolah Posts: 23Questions: 0Answers: 0
    thanks for the reply Allan. when I ran the json_direct_debits_edit.php, it gives this: (just to paste few records):
    {"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.
  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    That looks like the JSON reply for the 'get' - there are 10 records shown. What is the JSON reply for the 'create' Ajax request?

    Allan
  • femolahfemolah Posts: 23Questions: 0Answers: 0
    What is the JSON reply for the 'create' Ajax request?

    how do I check for the 'create' ajax request? sorry newby..

    Emmanuel.
  • femolahfemolah Posts: 23Questions: 0Answers: 0
    What is the JSON reply for the 'create' Ajax request?

    how do I check for the 'create' ajax request? sorry newby..

    Emmanuel.
  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    Using your browser's developer tools you will be able to see the Ajax request. Here is how to do it in Chrome: http://stackoverflow.com/questions/4939172/in-chrome-how-can-i-see-what-ajax-requests-are-being-made .

    We are interested in the Ajax request made after the Create / Save button has been pressed.

    Allan
  • femolahfemolah Posts: 23Questions: 0Answers: 0
    thanks for the reply Allan. I followed the instructions in stackoverflow. here is the copy of what it said after I clicked create button
    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
  • femolahfemolah Posts: 23Questions: 0Answers: 0
    I have taken the jQuery_Migrate-v1.2.js out, did not know why I put it in the header in the first place.. lol.

    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
  • femolahfemolah Posts: 23Questions: 0Answers: 0
    I have tried using ajaxSouce instead of DOM table source, all working ok. no warning, no errors.

    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. )
  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    The event.returnValue warning is coming from jQuery - you can safely ignore that.

    > 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
  • femolahfemolah Posts: 23Questions: 0Answers: 0
    i think the problem is with the datatables.editor.

    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
  • femolahfemolah Posts: 23Questions: 0Answers: 0
    ok. I will see what I can do to put my work on a site for you to have a look and I will see to zip it.

    thanks.
  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    That would be fantastic - thanks!

    Allan
  • femolahfemolah Posts: 23Questions: 0Answers: 0
    Hi Allan, please visit femiitconsultancy.co.uk/index.php, you will see the page there. it's the same thing occurring.

    I extracted this page from the main project.

    I will email you zip file as well.

    thanks.
  • femolahfemolah Posts: 23Questions: 0Answers: 0
    can't attach file using the contact on your site. but I hope the web link is sufficient enough..
  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    Brilliant - thanks! I think I've got it:

    > "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
  • femolahfemolah Posts: 23Questions: 0Answers: 0
    oh my gosh!!

    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.
  • allanallan Posts: 63,531Questions: 1Answers: 10,475 Site admin
    No problem at all - great to hear that it is now working! And thanks for putting up the test case.

    Allan
This discussion has been closed.