EasyUI Forum
September 19, 2025, 05:10:41 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Report one issue about checkbox in datagrid  (Read 16686 times)
Deiva
Newbie
*
Posts: 9


View Profile Email
« on: May 13, 2012, 06:19:44 AM »

using 1.26 version.

in the header, it has
Code:
<th field="LogId" width="20" align="center" checkbox="true"></th>
to define a check box and relate to LogId column.

But in broswer (Chrome, 17.0.963.56m), the checkbox html is converted to be

Code:
<td field="LogId"><div style="width:undefinedpx;text-align:center;height:auto;" class="datagrid-cell-check "><input type="checkbox"></div></td>

1. width value is not correct
2. hoping to bind 『LogId 』value to checkbox, as <input type="checkbox" value="XXX">, helping users to get much more customer data.

Thanks
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: May 14, 2012, 12:48:54 AM »

The ckeckbox field has fix width and will ignore 'width' property. To bind field value to checkbox, extend the datagrid view as below:
Code:
(function($){
var onAfterRender = $.fn.datagrid.defaults.view.onAfterRender;
$.extend($.fn.datagrid.defaults.view, {
onAfterRender: function(target){
onAfterRender.call(this, target);
var rows = $(target).datagrid('getRows');
$(target).datagrid('getPanel').find('tr[datagrid-row-index]').each(function(){
var ck = $(this).find('div.datagrid-cell-check input:checkbox');
if (ck.length){
var index = $(this).attr('datagrid-row-index');
var field = ck.parents('td:first[field]').attr('field');
var value = rows[index][field];
ck.attr('name',field).val(value);
}
});
}
});
})(jQuery);
Logged
Deiva
Newbie
*
Posts: 9


View Profile Email
« Reply #2 on: May 14, 2012, 06:25:06 AM »

Thank you so much!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!