我正在尝试在jsGrid的某个字段上动态插入ID。
我的实际字段是:
fields: [
{ name: "descricao", title: "Item", type: "text", width: "40%", validate: "required", align: "left", readOnly: true },
{ name: "codigoBarras", title: "Item", type: "text", width: "20%", validate: "required", align: "left", readOnly: true },
{ name: "quantidade", title: "Qtde", type: "text", width: "15%", align: "center", readOnly: true },
{
name: "precoCusto",
title: "Preço Custo",
type: "text",
align: "center",
width: "25%",
itemTemplate: function(value) {
return formatNumberForDisplay(value);
},
editTemplate: function(value) {
this.editControl = $("<input>").val(value);
update_on_enter(this.editControl);
return this.editControl;
}
},
{
type: "control",
deleteButton: false,
editButtonTooltip: "Editar dados",
cancelEditButtonTooltip: "Cancelar edição",
updateButtonTooltip: "Atualizar dados",
width: "10%"
}
]
用户将插入某些数据的唯一字段是“ precoCusto”字段。当用户单击第一行时,我要自动专注于该列的输入,当他按下时,请输入值自动更新,然后专注于下一行。我怎样才能做到这一点?我的“ update_on_enter”功能在这里:
function update_on_enter(field) {
console.log(field)
if(field[0].autofocus == false){
field[0].autofocus = true;
field[0].focus();
}
field.on("keydown", function(e) {
if (e.keyCode === 13) {
console.log(field)
field[0].value = field[0].value.replace(",",".")
$("#jsGrid").jsGrid("updateItem");
return false;
} else if (e.keyCode === 27) {
$("#jsGrid").jsGrid("cancelItem");
return false;
}
});
}