JQuery EasyUI - Как установить флажок или не отмечен в таблице easyui-datagrid td - PullRequest
0 голосов
/ 14 сентября 2018

я новичок в jeasyui. Я сгенерировал динамическую таблицу с easyui-datagrid и должен включить флажок для каждой строки. Теперь я хочу получить подробную информацию о каждой строке, когда установлен флажок, и снять флажок для конкретной строки.

<table id="process-list" title="Video Processing" class="easyui-datagrid" style="width:700px;height:250px"
        url="$/emplyoee/getfiles.action"
        idField="itemid">
    <thead>
        <tr>
     <th field='ck' checkbox="true"  type="checkbox" ></th> 
             <th field="id" width="50" >Id</th>              
            <th  field="createDate" width="50" >CreateDate</th>
            <th field="product" width="50">Product</th>             
            <th field="no.Files" width="50">No.Files</th>
            <th field="status" width="50">Status</th>
            <th field="cycle" width="50">Cycle</th>
        </tr>
    </thead>
</table>

$(document).ready(function() { 
$('input[name="ck"]').click(function(){
if($(this).prop("checked") == true){
    alert("Checkbox is checked.");
}
else if($(this).prop("checked") == false){
    alert("Checkbox is unchecked.");
}  

});

Я пробовал с функцией щелчка, но она не работает. });

1 Ответ

0 голосов
/ 14 сентября 2018

$('table').on('click','td input',function(){
if($(this).prop("checked") == true){
    alert("Checkbox is checked.");
}
else if($(this).prop("checked") == false){
    alert("Checkbox is unchecked.");
}  

});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td><input type="checkbox"></td>
    <td><input type="checkbox"></td>
    <td><input type="checkbox"></td>
  </tr>
  <tr>
   <td><input type="checkbox"></td>
    <td><input type="checkbox"></td>
    <td><input type="checkbox"></td>
  </tr>
  <tr>
   <td><input type="checkbox"></td>
    <td><input type="checkbox"></td>
    <td><input type="checkbox"></td>
  </tr>
  <tr>
   <td><input type="checkbox"></td>
    <td><input type="checkbox"></td>
    <td><input type="checkbox"></td>
  </tr>
  <tr>
    <td><input type="checkbox"></td>
    <td><input type="checkbox"></td>
    <td><input type="checkbox"></td>
  </tr>
  <tr>
   <td><input type="checkbox"></td>
    <td><input type="checkbox"></td>
    <td><input type="checkbox"></td>
  </tr>
</table>
...