2013-04-29 3 views
3

jQuery Datatable에서 간단한 인라인 편집을 구현하려고했습니다. 그러나 행 셀을 클릭 할 때 발생하는 편집을 활성화 할 수는 없습니다. 바인딩 데이터 테이블jQuery DataTable 인라인 편집

<table id="Datatable" cellpadding="0" cellspacing="0" border="0" class="display"> 
    <thead> 
     <tr> 
      <th>Age</th> 
      <th>Name</th> 
     </tr> 
    </thead> 
</table> 

: 어떤 제안이 높게 평가되어

/* Init DataTables */ 
    var oTable = $('#Datatable').dataTable({ 
     "bProcessing": true, 
     "sAjaxSource":"http://localhost:6220/DataSources/WCF/Data.svc/GetCustomer", 
     "aoColumns": [ 
          { "mDataProp": "Age" }, 
          { "mDataProp": "Name" } 
        ] 
    }); 

/* Apply the jEditable handlers to the table */    oTable.$('td').editable('http://localhost:6220/DataSources/WCF/Data.svc/SaveCustomer', { 
        tooltip: 'Click to edit...', 
        "callback": function (sValue, y) { 
         var aPos = oTable.fnGetPosition(this); 
         oTable.fnUpdate(sValue, aPos[0], aPos[1]); 
        }, 
        "submitdata": function (value, settings) { 
         return { 
          "row_id": this.parentNode.getAttribute('id'), 
          "column": oTable.fnGetPosition(this)[2] 
         }; 
        }, 
       "height": "14px", 
       "width": "100%" 
      }); 

나는 자신의 사이트 Link에서와 동일한 코드를 사용했다.

답변

9

-https://editor.datatables.net/examples/inline-editing/simple 홍보 . 작고 예쁜 베이직이지만 일을 끝내게됩니다. 의 repo는 여기에 있습니다 : DataTables CellEdit Plugin

기본 초기화를 빠르고 쉽게 :

oTable.MakeCellsEditable({ 
    "onUpdate": myCallbackFunction 
}); 

myCallbackFunction = function (updatedCell, updatedRow) { 
    console.log("The new value for the cell is: " + updatedCell.data()); 
} 

업데이트 :이 천천히 지난 몇 개월 동안 성장과 때 처음에 비해 꽤 많은 더 많은 기능을 가지고있다 이 답변을 게시했습니다. 거기에 참여한 모든 공헌자 덕분에!

+0

플러그인은 좋지만 추상적이지는 않습니다. 구성 할 수있는 플러그인이 너무 적습니다. – ROROROOROROR

+0

고맙습니다. github 페이지에서 기능 요청을 보내 주셔서 감사합니다. (또는 더 나은 방법으로 요청을 받으십시오 :-)) – Elliott

+1

좋아 보이지만 새로운 레코드를 추가 할 수있는 능력이 필요합니다. –