Im trying the slickgrid plugin ! I can red, edit and add data on the db when I press the "save" button. However, I was trying to do the same as excel, where you press the Enter key and it updates on the DB in real time. I get into the where the key is pressed, but then theres no data at all. It access the function, but then nothing happens. Any help ? Thanks in advance
I've tried with the grid.onAddNewRow.subscribe(function (e, args) from slickgrid itself but it just dont update. If i just insert one new row and the press "save" , it will add on the db!
$(document).keydown(function () {
var keyPressed = event.keyCode || event.which;
if (keyPressed == 13) {
console.log("im in");
grid.onAddNewRow.subscribe(function (e, args) {
var idData = jsonResult[key].id + 1;
var item = { "id": idData, "t_nome": "", "t_prof": "", "t_data": "", "t_morada": "", "t_percCompleto": "" };
$.extend(item, args.item);
dataView.addItem(item);
});
} else {
return true;
}
});
I was expecting that, after the user pressed the Enter key, it updated in real time on the DB but that does not happen.
P.S. Im using the var idData = jsonResult[key].id + 1
so It can increment on the grid .
This is what I got for solution
grid.onAddNewRow.subscribe(function (e, args) {
var idData = jsonResult[key].id + 1;
var item = { "id": idData, "t_nome": "", "t_prof": "", "t_data": "", "t_morada": "", "t_percCompleto": "" };
$.extend(item, args.item);
dataView.addItem(item);
grid.onKeyDown.subscribe(function (e) {
var keyPressed = event.keyCode || event.which;
if (keyPressed == 13) {
alert(item);
var myJSON = JSON.stringify(item);
$.post("/SlickTests/editGrid", $("input[name=mydata]").val(myJSON))
}
});
});`
But now its giving me a error of deserialize ( cannot deserialize the current JSON object into type 'System.Collections.Generic.List'! NEverless, got the answer ! Hope it helps someone :)