Field is not defined issue when add new record

4 posts, 0 answers
  1. IT
    IT avatar
    3 posts
    Member since:
    Nov 2016

    Posted 19 Oct 2018 Link to this post

    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?

  2. IT
    IT avatar
    3 posts
    Member since:
    Nov 2016

    Posted 19 Oct 2018 in reply to IT Link to this post

    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..

  3. IT
    IT avatar
    3 posts
    Member since:
    Nov 2016

    Posted 19 Oct 2018 in reply to IT Link to this post

    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..
  4. Preslav
    Admin
    Preslav avatar
    589 posts

    Posted 22 Oct 2018 Link to this post

    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.
Back to Top