Advertisement
rhuntington

JS Grid

Mar 10th, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let actions = [
  2.     { "Action": "Set" },
  3.     { "Action": "Mod" },
  4.     { "Action": "Strike" },
  5.     { "Action": "Carry" }
  6. ];
  7.  
  8. let rooms = [
  9.     { "Room": "Empire", id: 0 },
  10.     { "Room": "Empire A", id: 1 },
  11.     { "Room": "Empire B", id: 2 },
  12.     { "Room": "Empire C", id: 3 },
  13.  
  14. ];
  15.  
  16. $("#jsgrid").jsGrid({
  17.     width: "100%",
  18.     height: "400px",
  19.  
  20.     inserting: true,
  21.     editing: true,
  22.     sorting: true,
  23.     paging: true,
  24.  
  25.     // data: clients,
  26.  
  27.     fields: [
  28.         { name: "Room", type: "select", items: rooms, textField: "Room", valueField: "id", validate: "required" },
  29.         { name: "Action", type: "select", items: actions, textField: "Action", valueField: "Action" },
  30.         { name: "Note", type: "text" },
  31.         { name: "Day", type: "date" },
  32.         { type: "control" }
  33.     ],
  34.     controller: {
  35.         insertItem: (item) => {
  36.             if (item.Note == "") {
  37.                 item.Note = "-";
  38.             }
  39.             if (item.Action == "Mod") {
  40.                 $("#exampleModal").modal();
  41.             }
  42.             console.dir(item);
  43.         },
  44.  
  45.     },
  46.     onItemInsert: (item) => {
  47.         // After item has been inserted change value of cell for next insert in here (somehow)
  48.         console.dir(item);
  49.     }
  50. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement