Jsgrid: readOnly text field cannot be modified by script

Created on 17 Mar 2017  路  3Comments  路  Source: tabalinas/jsgrid

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?

help wanted

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:

onItemUpdating: function(args){
          var grid = args.grid
          grid.data[args.itemIndex].LastModified = new Date()
          grid.refresh()
        },

See a working example here

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vahidhiv picture vahidhiv  路  5Comments

flyinmryan picture flyinmryan  路  3Comments

bradybray picture bradybray  路  3Comments

comiscienceknight picture comiscienceknight  路  3Comments

julmot picture julmot  路  3Comments