Search code examples
angularjsangular-ui-grid

Checked the check box in ui-grid angular js


Using ui-grid in my project, i am getting JSON object from DB like Below

[
    {
        "checkbox1": {
            "fieldName": "checkbox1",
            "fieldValue": "Y"
        },
        "checkbox2": {
            "fieldName": "checkbox3",
            "fieldValue": "Y"
        },
        "checkbox3": {
            "fieldName": "checkbox3",
            "fieldValue": "N"
        }
    }
]

Below object is columnDef

[
    {
        "name": "checkbox1",
        "field": "checkbox1.fieldValue",
        "displayName": "checkbox1",
        "cellTemplate": '<input type=\"checkbox\" ng-model=\"{{COL_FIELD}}\" ng-true-value=\'Y\' ng-false-value=\'N\' />'
    },
    {
        "name": "checkbox2",
        "field": "checkbox2.fieldValue",
        "displayName": "checkbox2",
        "cellTemplate": '<input type=\"checkbox\" ng-model=\"{{COL_FIELD}}\" ng-true-value=\'Y\' ng-false-value=\'N\' />'
    },
    {
       "name": "checkbox3",
        "field": "checkbox3.fieldValue",
        "displayName": "checkbox3",
        "cellTemplate": '<input type=\"checkbox\" ng-model=\"{{COL_FIELD}}\" ng-true-value=\'Y\' ng-false-value=\'N\' />'
    }
];

After rendering the html, I am getting an error in the console:

Error: [$parse:syntax] http://errors.angularjs.org/1.5.0-rc.1/$parse/syntax?p0=%7B&p1=invalid%20key&p2=2&p3=%7B%7Bgrid.getCellValue(row%2Col)%7D%7D&p4=%7Bgrid.getCellValue(row%2C%col)%7D%7D

How can I resolve this issue?


Solution

  • Tutorial: 201 Edit Feature

    try to use 'boolean' type instead of 'checkbox'