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

DefaultValue not working for numbers

4 Answers 222 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
ANDRE
Top achievements
Rank 1
ANDRE asked on 28 Nov 2018, 11:25 AM

Hi all,

I try to set a default value for a numeric field. I can't figure out why it does not work.

I simply set default value this way : schema.model.fields.MyNumericField to {defaultValue : 9, type:"number"}.

All I get when I create a record is 0.

I join screenshot of entire schem model.

Thanks in advance for any help,

André.

4 Answers, 1 is accepted

Sort by
0
ANDRE
Top achievements
Rank 1
answered on 28 Nov 2018, 01:55 PM

After hours of research, I fixed it by putting the same default values in database schema. Is it the way it is supposed to work ? 

What if I need a different value than the default database value ? (Progress Database)

André.

0
Dimitar
Telerik team
answered on 30 Nov 2018, 10:03 AM
Hello Andre,

In general, the defaultValue parameter indicates the default value that will be used when a new model is created and depends on the type of the field. However, to answer your first question, I will need additional information. Therefore, could you elaborate a bit more on the database schema part and the exact scenario where the defaultValue is not working? It would be most helpful if you could provide an isolated example where the issue can be reproduced. I would suggest to open a separate support ticket where we can continue our communication. 

Concerning the different default value query - the parameter could be set as a function. Refer to the following HowTo example, where a similar scenario is demonstrated:


Regards,
Dimitar
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
ANDRE
Top achievements
Rank 1
answered on 30 Nov 2018, 10:16 AM

Hi Dimitar,

I wanted to set default values to numeric fields. That is when I create a record, I want the input fields to be set to the default value I supplied in model. In the Progress database, these integer fields had "0" as initlial value.

In my model, I set default value to -1. It did not work. I also tried to set default value to 9 in order to check wether negative value was the problem but it wasn't. Finally, I set initial value to -1 in the Progress database. After that, it works.

I can't figure out how to provide isolated example as database seems to be concerned.

Regards,

André.

 

0
Dimitar
Telerik team
answered on 03 Dec 2018, 11:05 AM
Hi Andre,

I would suggest to open a separate support thread, where you could provide additional details regarding the issue and the exact scenario. There, you could also send us an isolated solution that reproduces the issue. You should be able to use dummy data to construct the server response without the need to attach a specific database.

Regards,
Dimitar
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
Data Source
Asked by
ANDRE
Top achievements
Rank 1
Answers by
ANDRE
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or