2014-09-30 76 views
0

我有以下代碼(從網站的例子)jQuery的JTable中不執行的listAction功能

$('#reportsTableContainer').jtable({ 
    title: 'Table of people', 
    actions: { 
     listAction: function (postData, jtParams) { 
      ret = { 
       "Result": "OK", 
       "Records": [{ 
        "PersonId": 1, 
        "Name": "Benjamin Button", 
        "Age": 17, 
        "RecordDate": "\/Date(1320259705710)\/" 
       }] 
      } 
      return ret; 
     }, 
    }, 
    fields: { 
     PersonId: { 
      key: true, 
      list: false 
     }, 
     Name: { 
      title: 'Author Name', 
      width: '40%' 
     }, 
     Age: { 
      title: 'Age', 
      width: '20%' 
     }, 
     RecordDate: { 
      title: 'Record date', 
      width: '30%', 
      type: 'date', 
      create: false, 
      edit: false 
     } 
    } 
}); 
$('#reportsTableContainer').jtable('load'); 


}; // end initJTable 

當我運行它,我得到的控制檯 -

http://localhost/valuepro/valuepro/main/function%20(postData,%20jtParams)%20%7Bret%20=%20%7B%20%22Result%22:%22OK%22,%20%22Records%22:[%20%20%7B%22PersonId%22:1,%22Name%22:%22Benjamin%20Button%22,%22Age%22:17,%22RecordDate%22:%22//Date(1320259705710)//%22%7D,%20%20%7B%22PersonId%22:2,%22Name%22:%22Douglas%20Adams%22,%22Age%22:42,%22RecordDate%22:%22//Date(1320259705710)//%22%7D,%20%20%7B%22PersonId%22:3,%22Name%22:%22Isaac%20Asimov%22,%22Age%22:26,%22RecordDate%22:%22//Date(1320259705710)//%22%7D,%20%20%7B%22PersonId%22:4,%22Name%22:%22Thomas%20More%22,%22Age%22:65,%22RecordDate%22:%22//Date(1320259705710)//%22%7D%20]%7Dreturn%20ret;%7D 

即不是執行的該函數將它變成一個字符串並嘗試從SRV中獲取它。

這是爲什麼?這段代碼有什麼問題?

我應該如何從listAction執行一個函數,而不是從SRV中獲取數據?

回答

0

升級到版本2.4.0解決了這個問題