Advertisement
livitup

people/index.html.erb

Dec 12th, 2024
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. <% content_for :title, "People" %>
  2.  
  3. <h1>People</h1>
  4.  
  5. <div id="example-table"></div>
  6.  
  7. <script>
  8. //define some sample data
  9. var tabledata = [
  10. {id:1, name:"Oli Bob", age:"12", col:"red", dob:""},
  11. {id:2, name:"Mary May", age:"1", col:"blue", dob:"14/05/1982"},
  12. {id:3, name:"Christine Lobowski", age:"42", col:"green", dob:"22/05/1982"},
  13. {id:4, name:"Brendon Philips", age:"125", col:"orange", dob:"01/08/1980"},
  14. {id:5, name:"Margret Marmajuke", age:"16", col:"yellow", dob:"31/01/1999"},
  15. ];
  16.  
  17. //create Tabulator on DOM element with id "example-table"
  18. var table = new Tabulator("#example-table", {
  19. height:205, // set height of table (in CSS or here), this enables the Virtual DOM and improves render speed dramatically (can be any valid css height value)
  20. data:tabledata, //assign data to table
  21. layout:"fitColumns", //fit columns to width of table (optional)
  22. columns:[ //Define Table Columns
  23. {title:"Name", field:"name", width:150},
  24. {title:"Age", field:"age", hozAlign:"left", formatter:"progress"},
  25. {title:"Favourite Color", field:"col"},
  26. {title:"Date Of Birth", field:"dob", sorter:"date", hozAlign:"center"},
  27. ],
  28. });
  29.  
  30. //trigger an alert message when the row is clicked
  31. table.on("rowClick", function(e, row){
  32. alert("Row " + row.getData().id + " Clicked!!!!");
  33. });
  34. </script>
  35.  
  36. <%= link_to "New person", new_person_path %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement