EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Deiva on May 13, 2012, 06:19:44 AM



Title: Report one issue about checkbox in datagrid
Post by: Deiva 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


Title: Re: Report one issue about checkbox in datagrid
Post by: stworthy 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);


Title: Re: Report one issue about checkbox in datagrid
Post by: Deiva on May 14, 2012, 06:25:06 AM
Thank you so much!