This is a migrated thread and some comments may be shown as answers.

How to set Grid column defaultvalue at run time

1 Answer 304 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
Daochuen asked on 19 Sep 2020, 07:03 AM

Hello,

I tried to set Grid column defaultvalue at run time as below code. but "Jenny" does not display in "FirstName" column when I add new record. Could anyone give me advice how to do it?  Thanks in advance.

in .cshtml file:
 .Edit("onEdit");

In javascript:

   function onEdit(e) {
        if (e.model.isNew()) {
          
            e.model.set("FirstName", "Jenny");
         
        }
   }

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 22 Sep 2020, 01:13 PM

Hi,

I have tested the same on my end and it appears to work as expected.

Is it possible that the FirstName field is configured as not editable?

e.g.

model.Field(p => p.FirstName).Editable(false);

 

Regards,
Georgi
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Grid
Asked by
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Georgi
Telerik team
Share this question
or