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

New record can not display default value.

2 Answers 174 Views
Grid
This is a migrated thread and some comments may be shown as answers.
dcs
Top achievements
Rank 1
dcs asked on 06 Jul 2019, 12:11 AM
Setting a default value can be configured via the DefaultValue option in the DataSource Model configuration. My Code would look similar to this:
.DataSource(dataSource => dataSource
   .WebApi()
   .Create(create => create.Action("Create", "Home"))
   .Update(update => update.Action("Update", "Home"))
   .Read(read => read.Action("Read", "Home"))
   .Model(m => {
        m.Id(id => id.Id);
        m.Field(f => f.Name).DefaultValue("test");
    })
)
After I click on the "Add new record" button, the new row can display,but Name cann't display "test". why?

2 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 10 Jul 2019, 03:48 PM
Hello,

I am afraid that with our last official release we introduced a regression bug that affects applying default values with some fields (in this case string type of fields). Currently we are working on fixing this problem with highest priority and I will let you know in this thread when the fix will be available in the latest internal build. 

In the meantime you can sue the BeforeEdit event in order to apply a default value as shown below: 

.Events(e=>e.BeforeEdit("onBeforeEdit"))
<script>
    function onBeforeEdit(e) {
      if(e.model.isNew()){
        e.model.ContactName = "Test";
      }
    }
</script>


Thank you for understanding. 

Regards,
Boyan Dimitrov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Boyan Dimitrov
Telerik team
answered on 18 Jul 2019, 02:52 PM
Hello,

I am glad to inform you that the issue with not applying default values is resolved in our Latest Internal Build (2019.2.718). I would like to encourage you to download the LIB from your account and let us know how that worked. 

Regards,
Boyan Dimitrov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
dcs
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or