Title: Using onAdd to set default values in an Editable Datagrid Post by: mschnitter on January 03, 2021, 09:53:30 PM Hello,
I'm using an Editable Datagrid to perform some basic CRUD functions. I would like to set default values when a new row is added to the datagrid. I read through the documentation and saw that the onAdd event seemed like the perfect place to do this. Created the following method: onAdd: function(index,row){ row.Key = 'U'; row.Status = 'N'; } Key and Status are two columns in my datagrid. When I run my code, nothing happens. When I step through with the browser JS debugger, it looks like row is not used the same way as other examples that have a seen. I haven't found an example of using onAdd to set default values when a row is added in an edatagrid. I'm beginning to wonder if I'm approaching this the wrong way. Any Thoughts? Thanks Title: Re: Using onAdd to set default values in an Editable Datagrid Post by: jarry on January 05, 2021, 12:24:52 AM If you have the editor on the column, you can get the editor and set its value after adding a row.
Code: onAdd: function(index,row){ You can also set any row values before editing a row. Code: onBeforeEdit: function(index,row){ Title: Re: Using onAdd to set default values in an Editable Datagrid Post by: mschnitter on January 05, 2021, 07:47:09 AM Hi Jarry,
Thank You!! That did the trick. I played with the $(ed.target) reference in the debugger, and found that very helpful. I was able to set defaults for the fields I needed in the onAdd event. Thanks Again |