2013-06-21 17 views
0

我有一個用很棒的DataTable jQuery插件顯示的表格(在asp.net中生成)。 我的表格有一些可編輯的字段(我使用了jQuery Datatables editable),我的一些表格中已經有了一些自定義字段。在編輯複選框時使用jQuery可編輯數據表中的自定義字段

這是一張只有3°可編輯列的表,它發送了兩個額外的參數(我的表的第3列和第1列):「cell」和「trustedid」。這完美的作品:

$('#ctl00_MainContent_tradGrid').dataTable({ 
    bJQueryUI: true, 
    "sPaginationType": "full_numbers", 
    "bSortClasses": false 
    }).makeEditable({ 
     sUpdateURL: "/updateData.aspx<% Response.Write(parameters); %>", 
     fnOnEditing: function (input) { 
      cell = input.parents("tr") 
        .children("td:nth-child(3)") 
        .text(); 
      trustedid = input.parents("tr") 
        .children("td:nth-child(1)") 
        .text(); 
      return true 
     }, 
     oUpdateParameters: { 
      cell: function() { return cell; }, 
      trustedid: function() { return trustedid; } 
     }, 
     oEditableSettings: { event: 'click' } 
    }); 

我也有在最後一個可編輯欄的複選框另一個表中,也能正常工作,這是代碼:

$('#ctl00_MainContent_tradGrid').dataTable({ 
    bJQueryUI: true, 
    "sPaginationType": "full_numbers", 
    "bSortClasses": false 
}).makeEditable({ 
    sUpdateURL: "/updateChecked.aspx", 
    aoColumns: [ 
     {}, {}, {}, { 
      type: 'checkbox', 
      submit: 'Ok', 
      cancel: 'Cancel', 
      checkbox: { trueValue: 'Yes', falseValue: 'No' } 
     } 
    ] 
}); 

現在我需要使用一個自定義的參數這第二個例子,但不能做到這一點!這是我的嘗試:

$('#ctl00_MainContent_tradGrid').dataTable({ 
    bJQueryUI: true, 
    "sPaginationType": "full_numbers", 
    "bSortClasses": false 
}).makeEditable({ 
    sUpdateURL: "/updateChecked.aspx", 
    fnOnEditing: function (input) { 
     trustedid = input.parents("tr") 
       .children("td:nth-child(1)") 
       .text(); 
     return true 
    }, 
    oUpdateParameters: { 
     trustedid: function() { return trustedid; } 
    }, 
    aoColumns: [ 
     {}, {}, {}, { 
      type: 'checkbox', 
      submit: 'Ok', 
      cancel: 'Cancel', 
      checkbox: { trueValue: 'Yes', falseValue: 'No' } 
     } 
    ] 
}); 

,但它得到的錯誤:Uncaught ReferenceError: trustedid is not defined

我怎麼能這樣做呢?

回答

0

fnOnEditing僅在text,select和textarea中調用: if(settings.type == "text" || settings.type == "select" || settings.type == "textarea") 圍繞jquery.dataTables.editable.js中的第209行。我用它與一些自動完成的領域,它的工作。您可以在該列表中添加複選框,但可能您還需要其中的一些其他更改,因爲複選框上的.val()不會返回正確的值。