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

Field is not defined issue when add new record

3 Answers 517 Views
Grid
This is a migrated thread and some comments may be shown as answers.
IT
Top achievements
Rank 1
IT asked on 19 Oct 2018, 06:24 AM

hello,

I want to use grid columns like this;

columns: [{
field: "ph___10",
width: "100px",
title:"ph",
attributes: {
class: "#=ph___10 == -10 ? 'yellow' : ph___10 < 7 ? 'green' : 'red' #"
}}]

But get error when i use field name like 'ph___10' in attributes->class.

If i use field name like for example 'ph', no problem. I have to use '_' and '10' characters. 

Can u help me?

3 Answers, 1 is accepted

Sort by
0
IT
Top achievements
Rank 1
answered on 19 Oct 2018, 12:35 PM

I solved this problem. If u want to use like

attributes: {
class: "#=ph___10 == -10 ? 'yellow' : ph___10 < 7 ? 'green' : 'red' #"
}}]

U must add (for example) "ph___10" to schema -> model -> fields

and then it will run..

0
IT
Top achievements
Rank 1
answered on 19 Oct 2018, 12:36 PM
I solved this problem. If u want to use like this;

attributes: {
class: "#=ph___10 == -10 ? 'yellow' : ph___10 < 7 ? 'green' : 'red' #"
}}]

u must add (for example) "ph___10" to schema -> model -> fields

and then it will run..
0
Preslav
Telerik team
answered on 22 Oct 2018, 08:14 AM
Hello,

The provided solution looks good.

Another possible approach is to use the "schema.model.fields.field.from" property, and change the field name for the client dataSource. For example:

dataSource: {
  data: userData,
  schema: {
    model: {
      fields: {
        name: {
          type: "string"
        },
        ph: {
          from: "ph___10",
          type: "number"
        }
      }
    }
  }
},

For a runnable example, check this Dojo:

Regards,
Preslav
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
IT
Top achievements
Rank 1
Answers by
IT
Top achievements
Rank 1
Preslav
Telerik team
Share this question
or