2016-02-04 66 views
1

在我的項目中使用的UI網,我得到的JSON對象從DB像下面選中複選框在UI格角JS

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

下面對象是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\' />' 
    } 
]; 

渲染後html的,我在控制檯收到一個錯誤:

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

我該如何解決這個問題?

+0

很難確切地知道它是錯誤的,但你必須有某種語法錯誤在你的HTML。錯誤的線索在查詢字符串中:'p0 = {&p1 = invalid key&p2 = 2&p3 = {{grid.getCellValue(row,ol)}}&p4 = {grid.getCellValue(row,col)}}'.. 。你可能拼錯了'col',或者你可能錯過了一個大開大括號。也有助於看到控制器/ html代碼。 –

回答

2

http://ui-grid.info/docs/#/tutorial/201_editable

嘗試使用「布爾」類型,而不是「複選框」

+0

Hi @ un.spike,小疑問,我從數據庫中獲得1000條記錄,在這兩列複選框中,但在服務調用UI沒有正確響應的情況下,它會觸發3或4分鐘,請您提出任何想法或任何解決此問題的方法,請提前致謝! – Coder

+0

我無法取消選中選中的複選框,我無法檢查未選中的複選框,您是否有任何想法,任何可能出錯的地方,都可以請建議。 '' – Coder

+0

設置enableCellEdit:true,在colDef –