Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: jquery datatables, edycja tabeli
Forum PHP.pl > Forum > Po stronie przeglądarki > JavaScript
Tomasz7755
czesc

Chcialbym przelozyc przyklad z tego linka: https://editor.datatables.net/examples/simple/multiRow.html

Jednak chcialbym aby dane byly pobierane z tabeli HTML, nie z ajaxa.
Dostaje niestety komunikat: TypeError: $.fn.dataTable.Editor is not a constructor

Moj kod :

  1. <!DOCTYPE html>
  2.  
  3.  
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.  
  7. <link rel="stylesheet" href="css/jquery.dataTables.min.css" >
  8. <link rel="stylesheet" href="css/buttons.dataTables.min.css" >
  9. <link rel="stylesheet" href="css/select.dataTables.min.css" >
  10. <link rel="stylesheet" href="css/editor.dataTables.min.css" >
  11.  
  12. <script src="js/jquery.js"></script>
  13. <script src="js/jquery.dataTables.min.js"></script>
  14. <script src="js/dataTables.buttons.min.js"></script>
  15. <script src="js/dataTables.select.min.js"></script>
  16. <script src="js/dataTables.editor.min.js"></script>
  17.  
  18. var editor; // use a global for the submit and return data rendering in the examples
  19.  
  20. $(document).ready(function() {
  21. editor = new $.fn.dataTable.Editor( {
  22. table: "#example",
  23. fields: [ {
  24. label: "First name:",
  25. name: "first_name"
  26. }, {
  27. label: "Last name:",
  28. name: "last_name"
  29. }, {
  30. label: "Position:",
  31. name: "position"
  32. }, {
  33. label: "Office:",
  34. name: "office"
  35. }, {
  36. label: "Extension:",
  37. name: "extn"
  38. }, {
  39. label: "Start date:",
  40. name: "start_date",
  41. type: "datetime"
  42. }, {
  43. label: "Salary:",
  44. name: "salary"
  45. }
  46. ]
  47. } );
  48.  
  49. $('#example').DataTable( {
  50.  
  51. select: true,
  52. buttons: [
  53. { extend: "create", editor: editor },
  54. { extend: "edit", editor: editor },
  55. { extend: "remove", editor: editor }
  56. ]
  57. } );
  58. } );
  59. </script>
  60. </head>
  61. <table id="example" class="display" cellspacing="0" width="100%">
  62. <tr>
  63. <th>Name</th>
  64. <th>Position</th>
  65. <th>Office</th>
  66. <th>Extn.</th>
  67. <th>Start date</th>
  68. <th>Salary</th>
  69. </tr>
  70. </thead>
  71. <tr>
  72. <th>Name</th>
  73. <th>Position</th>
  74. <th>Office</th>
  75. <th>Extn.</th>
  76. <th>Start date</th>
  77. <th>Salary</th>
  78. </tr>
  79. </tfoot>
  80. <tr>
  81. <td>Airi Satou</td>
  82. <td>Accountant</td>
  83. <td>Tokyo</td>
  84. <td>5407</td>
  85. <td>2008-11-28</td>
  86. <td>$162,700</td>
  87. </tr>
  88. <tr>
  89. <td>Brenden Wagner</td>
  90. <td>Software Engineer</td>
  91. <td>San Francisco</td>
  92. <td>1314</td>
  93. <td>2011-06-07</td>
  94. <td>$206,850</td>
  95. </tr>
  96. <tr>
  97. <td>Brielle Williamson</td>
  98. <td>Integration Specialist</td>
  99. <td>New York</td><td>4804</td>
  100. <td>2012-12-02</td>
  101. <td>$372,000</td>
  102. </tr>
  103. </tbody>
  104. </body>


Moze wiecie gdzie lezy przyczyna bledu? smile.gif
emstawicki
Może od rzeczy prostej. Upewniłeś się czy wszystkie pliki js wczytują się prawidłowo?
Tomasz7755
Jasne, zarowno pliki js jak i css sa wczytywane tak jak trzeba. Sprawdzilem to otwierajac zrodlo strony i klikajac na kazdy po kolei.

Znalazlem inny przyklad, taki ktory potrzebuje, skopiowalem wszystko identycznie jak jest na stronie jednak dalej mi wyrzuca ze "$.fn.dataTable.Editor is not a constructor"

Link do przykladu : https://editor.datatables.net/examples/adva.../htmlTable.html

Moze ktos z was sprawdzi i ogarnie co jest nie tak ?:-)
trueblue
Nic innego (inny błąd) w konsoli się nie wyświetla?
Tomasz7755
Dostaje jeszcze informacje o tym, zeby nie kopiowac tego pliku na lokalny dysk:
uncaught exception: DataTables Editor - remote hosting of code not allowed. Please see http://editor.datatables.net for details on how to purchase an Editor license

Wiec zmienilem sciezke z mojego dysku na link do strony datatables: https://editor.datatables.net/extensions/Ed...s.editor.min.js

jednak dalej jest to samo
Tomasz7755
dzieki, czyli widze ze trzeba pobrac ten plik z wersja trial. Tylko nigdzie ,nie widze informacji o cenie po okresie 15 dni, wiesz moze gdzie ona sie znajduje ?smile.gif
trueblue
https://editor.datatables.net/purchase/
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.