DataTables / Editor integration with Joomla

DataTables / Editor integration with Joomla

agustin_garciaromeroagustin_garciaromero Posts: 42Questions: 0Answers: 0
edited September 2012 in General
Hello,
I'm trying to integrate DataTables 1.9.3 and Editor 1.2.1 in a Joomla enviroment, but I'm having issues when calling the JS DataTable file from a Joomla URL.

I mean, if I call the Editor generated HTML file, everything works fine:
http://localhost/pfm/administrator/components/com_pfm/libraries/jq/DataTables193/test.html
(Somehow I was able to understand that the PHP file is being called like: "administrator/components/com_pfm/libraries/jq/DataTables193/php/table.test.php?_=1347145007027"

But if I call the table.test.js file directly from a Joomla component, I receive the following errors:
"NetworkError: 404 Not Found - http://localhost/pfm/php/table.test.php?_=1347145007027"
NetworkError: 404 Not Found - http://localhost/pfm/images/calender.png"

It seems like calling the JS from the HTML file generated by Editor is enabling DataTables/Editors to understand the pathname where it's being called and generating a random ID [table.test.php?_=1347145007027], but calling it from outside is somehow missing that and the constructed URL is incomplete: [ 'http://localhost/pfm/php/table.test.php' vs. 'administrator/components/com_pfm/libraries/jq/DataTables193/php/table.test.php']


Hope I'm making myself clear on the issue I'm facing and some guidance can be provided.
Tnx

Replies

  • allanallan Posts: 63,180Questions: 1Answers: 10,411 Site admin
    Is Joomla doing some kind of URL rewriting perhaps? Or possibly you use need to modify the paths which have been put into the generated files? Making them absolute rather than relative might alleviate the problem.

    Allan
  • agustin_garciaromeroagustin_garciaromero Posts: 42Questions: 0Answers: 0
    Yes, I'm trying to make absolute the URLs being referred in the DataTables/Editor components, but I wasn't able to understand where a link as "table.test.php?_=1347145007027" is being generated and how it's built.

    In previous version of Editor, I just had to hardcode the following vars on the JS file to make absolute the URLs reference
    "ajaxUrl"
    "sAjaxSource"
    "sSource" (if I used "fnServerData" callback function)

    But on Editor 1.2.1 is not working anymore, not sure if you can guide me on where such path is being generated and where can I catch it and make it an absolute one
    tnx
  • agustin_garciaromeroagustin_garciaromero Posts: 42Questions: 0Answers: 0
    Hello,
    Any comment on this one?
    I'm still unable to see how it works
    Regards
  • allanallan Posts: 63,180Questions: 1Answers: 10,411 Site admin
    So that worked with Editor 1.2.0 but not 1.2.1? I don't really understand why that would be that case as nothing has change in that area. I think I would need to actually see the page to fully understand the problem if you can give me a link please?

    Allan
  • agustin_garciaromeroagustin_garciaromero Posts: 42Questions: 0Answers: 0
    Hello,
    I solved this issue by replacing the dots with underscores on the file names (dataTables_editor_min.js, dataTables_tabletools_min.js, jquery_dataTables_min.js, dataTables_tabletools.css, dataTables_editor.css, jquery_dataTables.css)


    Now, I'm facing a new error -see below-, when trying to edit any record, which isn't shown on 1.2.0 but it does on 1.2.1
    It can be found @ http://royalelandscaping.com/pfm/index.php?option=com_pfm
    Regards

    [/code]
    Notice: Undefined property: DataTables\Editor\Field::$name in /home/royalela/public_html/pfm/administrator/components/com_pfm/libraries/jq/DataTables193/php/lib/Editor/Editor.php on line 319
    {"id":-1,"error":"","fieldErrors":[{"name":null,"status":null},{"name":null,"status":null},{"name":null,"status":"This field is required"},{"name":null,"status":"This field is required"},{"name":null,"status":"This field is required"},{"name":null,"status":null},{"name":null,"status":"This field is required"}],"data":[]}
    [/code]
  • allanallan Posts: 63,180Questions: 1Answers: 10,411 Site admin
    What does your Editor class initialisation look like?

    Allan
  • agustin_garciaromeroagustin_garciaromero Posts: 42Questions: 0Answers: 0
    Hello,
    I'm not sure what do you mean with your question, Is it about the Editor version?
    * File: dataTables.editor.min.js, * Version: 1.2.1

    When clicking on "Edit" button, all fields show up correctly filled, with all options enabled.
    But if I edit any text field and click on "Update", it shows me a legend like: "An error has occurred - Please contact the system administrator"

    The response text looks like:
    Notice: Undefined property: DataTables\Editor\Field::$name in /home/royalela/public_html/pfm/administrator/components/com_pfm/libraries/jq/DataTables193/php/lib/Editor/Editor.php on line 319

    {"id":-1,"error":"","fieldErrors":[{"name":null,"status":null},{"name":null,"status":null},{"name":null,"status":null}],"data":[]}


    Is this what you are asking for?
  • agustin_garciaromeroagustin_garciaromero Posts: 42Questions: 0Answers: 0
    Hello,
    Any comment here? Should I look into something else to find what's going on?
  • allanallan Posts: 63,180Questions: 1Answers: 10,411 Site admin
    > Is this what you are asking for?

    Not quite - I'm looking for the code that you use to create the Editor instance. How are you initliaisting it? Given the PHP error, you might also need to give us the PHP code.

    Allan
  • agustin_garciaromeroagustin_garciaromero Posts: 42Questions: 0Answers: 0
    Hi there,

    The code is the self generated by the system but instead of HTML, I had to rename it as PHP, remove the head tag and use a helper to include the CSS/JS files

    [code]
    ...



    DataTables Editor





    Family linked
    Recipient ID
    From\/To
    Recipient
    Category
    Amount
    Estimated?
    Periodicity
    Next Discount Date
    Automatic Tracking
    Linked Account
    Bill Reminder
    Income Type
    Memo






    ....
    [/code]
  • allanallan Posts: 63,180Questions: 1Answers: 10,411 Site admin
    I'm looking for the code for how you are actually initialising Editor - it will look something like:

    [code]
    editor = new $.fn.dataTable.Editor( { ...
    [/code]

    Allan
  • agustin_garciaromeroagustin_garciaromero Posts: 42Questions: 0Answers: 0
    Hello,
    The code is the same as generated by the Editor, except that I have to specify the URL for the .php file, since for some reason, within my Joomla environment it's not automatically found by the .js

    [code]
    strUrlDT = 'http://' + window.location.host + (window.location.pathname).replace(/index.php$/, "") + "administrator/components/com_pfm/libraries/jq/DataTables193/";

    var editor = new $.fn.dataTable.Editor( {
    "ajaxUrl": strUrlDT + 'php/table.test.php',
    "domTable": "#test",
    ...

    [/code]

    Can you guide me on where the randmo ID is being generated ("table.test.php?_=1347145007027") this may lead me to determine if I must build the above path differently
    Regards
  • allanallan Posts: 63,180Questions: 1Answers: 10,411 Site admin
    The underscore is most likely jQuery's anti-cache parameter (if you are using the default fnServerData, then that's what it is). It just stops the request from being cached.

    I see - so you have created the Editor setup with Generator and are trying to integrate those files? In that case, I'm afraid it might be that you need to ask in a Joomla forum how the path rewriting works in Joomla. There must be a way of telling it that you just want to load Ajax data from a file at a certain location!

    Allan
  • agustin_garciaromeroagustin_garciaromero Posts: 42Questions: 0Answers: 0
    Thanks Allan,
    Sure I can check with them. I touched base here first, because as I mentioned, the approach I'm using here used to work correctly with your previous version of DataTables, but when I tried to migrate to the one you released couple of weeks ago, it stopped working and I noticed the underscore and self generated ID behavior, which I didn't notice before.

    So I thought some of the changes you made on your framework should be the reason, but I agree with you, if it works in a standalone deployment, I should be able to integrate in other environments (e.g. Joomla)
    Regards
This discussion has been closed.