I have a field as follows:
{ name: "UpdatedBy", type: "text", "Updated By", readOnly: true }
and I want to fill it with the id of the user updating it:
onItemUpdating: function(args) {
args.item.UpdatedBy = "xxxx";
}
I put a breakpoint and find that, on subsequent hits after the first, the variable args.item.UpdatedBy contains my value I updated at the first onItemUpdating event. However, the grid does not show this value.
Is this by design? Can readOnly fields be modified by script?
onItemUpdating is simply a callback that passes the item by value.
In order to modify the data in the grid, you need to go about doing it a different way:
onItemUpdating: function(args){
var grid = args.grid
grid.data[args.itemIndex].LastModified = new Date()
grid.refresh()
},
See a working example here
Beautiful! Thanks.
Another question: onItemUpdating fires when the editing is done, ie green tick is clicked. Is there an event that fires upon entering into edit mode?
@RevealedFrom onItemEditing should work
Most helpful comment
onItemUpdating is simply a callback that passes the item by value.
In order to modify the data in the grid, you need to go about doing it a different way:
See a working example here