2012-12-04 3 views
0

jquery-datatables-editable을 사용하고 있으며 업데이트시 게시되는 값을 설정하려고합니다.
설명서에 따르면 aoColumns에 속하는 sName 속성을 설정하면이 작업을 수행 할 수 있습니다.
나는 행운과 함께 aoColumns와 aoColumnDefs에 정의하는 두 예제 모두를 시도했다.jquery-datatables-editable sName이 작동하지 않습니다.

아이디어가 있으십니까?
코드 샘플; 감안

:

<?php 
<div> 
    <button id="p_btnAddNewRow">Add</button> 
    <button id="p_btnDeleteRow">Delete</button> 

    <div id="p-container"> 
     <table cellpadding="0" cellspacing="0" border="0" class="display" id="p-table"> 
      <thead> 
       <tr> 
        <th>ID</th> 
        <th>Name</th> 
        <th>Notes</th> 
       </tr> 
      </thead> 
      <tbody> 
       <?php 
       if (isset($p['primary']) && is_array($p['primary']) && (count($p['primary']) > 0)) { 
        foreach ($p['primary'] as $primary) { 
       ?> 
       <tr id="<?php echo $primary->id; ?>"> 
        <td><?php echo $primary->code; ?></td> 
        <td><?php echo $primary->name; ?></td> 
        <td><?php echo $primary->notes; ?></td> 
       </tr> 
       <?php 
        } 
       } 
       ?> 
      </tbody> 
     </table> 
    </div> 
</div> 
?> 

JS; 내가 답을 발견

(
    [value] => test 
    [id] => 2784 
    [rowId] => 0 
    [columnPosition] => 0 
    [columnId] => 0 
    [columnName] => ID <- should be **code** 
) 
+0

이 연결된 배열을 생성하는 데 실제로 사용 된 코드를 표시하면 도움이됩니다. – Codeguy007

+0

@ Codeguy007 $ _POST의 print_r에있는 샘플 응답 – Rooneyl

+0

다시 코드를 표시하십시오. 웹 페이지 또는 jquery가 잘못된 데이터를 게시하는 경우 해당 데이터가 어떻게 생성되는지 확인해야합니다. – Codeguy007

답변

0

:

<script type="text/javascript"> 

var pTable; 
$(function() { 
    pTable = $('#primary-audiences-table').dataTable().makeEditable({ 
     sAddNewRowFormId: "p_formAddNewRow", 
     sAddNewRowButtonId: "p_btnAddNewRow", 
     sAddURL: "/templates/ptable/add", 
     fnOnNewRowPosted: function(data) { 
          if(data.indexOf("Error", 0) == 0) { 
           //Show error message 
           return false; 
          } else { 
           //Show success message and add row 
           return true; 
          } 
         }, 
     sUpdateURL: "/templates/ptable/edit", 
     sDeleteRowButtonId: "p_btnDeleteRow", 
     sDeleteURL: "/templates/ptable/delete", 
     "aoColumns": [ 
         { 
          sName: 'code', 
          indicator: 'Saving ID...', 
          tooltip: 'Double Click to edit', 
          type: 'textarea', 
          submit: 'Save changes' 
         }, 
         { 
          sName: 'name', 
          indicator: 'Saving name...', 
          tooltip: 'Double Click to edit', 
          type: 'textarea', 
          submit: 'Save changes' 
         }, 
         { 
          sName: 'notes', 
          indicator: 'Saving notes...', 
          tooltip: 'Double Click to edit', 
          type: 'textarea', 
          submit: 'Save changes' 
         } 
       ] 
    }); 
}); 

샘플 응답 ($ _POST의 인 print_r() 나 먹으 렴) 프로그래머에게 더 많은 커피를 제공하고 적절하게 문서를 읽어!

SNAME 특성

dataTables에 관련되어 확장, NOT makeEditable 확장 . 이 문서의 예제에는이 내용이 나와 있지만 제대로 읽지 못했습니다. 내 잘못이야.

따라서 올바른 쓰기 방법은 다음과 같습니다.

<script type="text/javascript"> 

var pTable; 
$(function() { 
    pTable = $('#primary-audiences-table').dataTable({ 
     aoColumns: [ {"sName": "code"}, {"sName": "name"}, {"sName": "notes"} ] 
    }).makeEditable({ 
     sAddNewRowFormId: "p_formAddNewRow", 
     sAddNewRowButtonId: "p_btnAddNewRow", 
     sAddURL: "/templates/ptable/add", 
     fnOnNewRowPosted: function(data) { 
          if(data.indexOf("Error", 0) == 0) { 
           //Show error message 
           return false; 
          } else { 
           //Show success message and add row 
           return true; 
          } 
         }, 
     sUpdateURL: "/templates/ptable/edit", 
     sDeleteRowButtonId: "p_btnDeleteRow", 
     sDeleteURL: "/templates/ptable/delete", 
     "aoColumns": [ 
         { 
          indicator: 'Saving ID...', 
          tooltip: 'Double Click to edit', 
          type: 'textarea', 
          submit: 'Save changes' 
         }, 
         { 
          indicator: 'Saving name...', 
          tooltip: 'Double Click to edit', 
          type: 'textarea', 
          submit: 'Save changes' 
         }, 
         { 
          indicator: 'Saving notes...', 
          tooltip: 'Double Click to edit', 
          type: 'textarea', 
          submit: 'Save changes' 
         } 
       ] 
    }); 
}); 

</script> 
관련 문제