rhuntington icon

JS Grid

rhuntington | PRO | 03/11/20 03:59:59 AM UTC | 0 ⭐ | 314 👁️ | Never ⏰ | []
JavaScript |

1.25 KB

|

None

|

0 👍

/

0 👎

let actions = [
    { "Action": "Set" },
    { "Action": "Mod" },
    { "Action": "Strike" },
    { "Action": "Carry" }
];
 
let rooms = [
    { "Room": "Empire", id: 0 },
    { "Room": "Empire A", id: 1 },
    { "Room": "Empire B", id: 2 },
    { "Room": "Empire C", id: 3 },
 
];
 
$("#jsgrid").jsGrid({
    width: "100%",
    height: "400px",
 
    inserting: true,
    editing: true,
    sorting: true,
    paging: true,
 
    // data: clients,
 
    fields: [
        { name: "Room", type: "select", items: rooms, textField: "Room", valueField: "id", validate: "required" },
        { name: "Action", type: "select", items: actions, textField: "Action", valueField: "Action" },
        { name: "Note", type: "text" },
        { name: "Day", type: "date" },
        { type: "control" }
    ],
    controller: {
        insertItem: (item) => {
            if (item.Note == "") {
                item.Note = "-";
            }
            if (item.Action == "Mod") {
                $("#exampleModal").modal();
            }
            console.dir(item);
        },
 
    },
    onItemInsert: (item) => {
        // After item has been inserted change value of cell for next insert in here (somehow)
        console.dir(item);
    }
});

Comments