EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: cohoman on September 30, 2013, 08:11:56 PM



Title: Two checkboxes in datagrid auto checking together?
Post by: cohoman on September 30, 2013, 08:11:56 PM
I'm trying to use a datagrid to display a few rows of data with two columns containing a checkbox each. The problem I'm having, is that when I click one of the checkboxes in a row, the 2nd checkbox in that same row gets checked automatically (and vice-versa). Below is an example of what I'm doing. Is there a way to have two independent checkboxes in separate columns of a datagrid on the same row?

Thanks for the help!

cohoman

Code:
<body>

<table id="process-list" title="Video Processing" class="easyui-datagrid" style="width:700px;height:250px"
url="data/datagrid_data.json"
idField="itemid">
<thead>
<tr>
<th field="scan" checkbox="true">Scan</th>
<th field="cut" checkbox="true">Cut</th>
<th field="filename" width="80">Video File</th>
<th field="duration" width="120">Duration</th>
<th field="status" width="80">Status</th>
</tr>
</thead>
</table>

</body>

<script>

  jQuery("#process-list").datagrid({ data:[{filename:'rabid dog.mp4',duration:'45:25'},
                                           {filename:'hazard pay.mp4',duration:'46:25'},
                                           {filename:'granite state.mp4',duration:'47:25'}]});

</script>


Title: Re: Two checkboxes in datagrid auto checking together?
Post by: stworthy on October 01, 2013, 07:20:27 AM
There is only one build-in 'checkbox' column in a row. But you can use 'formatter' function to define your own 'checkbox' columns, just like this.
Code:
<script>
function formatCk(value){
return '<input type="checkbox" value="'+value+'">';
}
</script>
<th field="scan" width="60" formatter="formatCk">Scan</th>
<th field="cut" width="60" formatter="formatCk">Cut</th>


Title: Re: Two checkboxes in datagrid auto checking together?
Post by: cohoman on October 02, 2013, 09:31:26 PM
Great. Thanks for the suggestion and help!