EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: A-K on August 11, 2014, 12:23:30 AM



Title: question about checkbox in datagrid
Post by: A-K on August 11, 2014, 12:23:30 AM
Hey, I need to use checkbox in datagrid but I need it to have a title like every other column and also width.
So I created a formatter for the row but I have a few problems:
1) Im trying to give it a default state for each row by the value of the field, If its true then its checked and false is unchecked.
The values in the field are true or false so I tried:
Code:
formatter: function(value,row,index){
return '<input type="checkbox" value="'+value+'">';
}

and also:

Code:
formatter: function(value,row,index){
return '<input type="checkbox" checked="'+value+'">';
}

both doesnt work well.

2) When pressed on the checkbox the row will get selected/unselected and since its created via formatter the 'selectOnCheck = false' propertie doesnt work, how can I make the row not to be
selected when the checkbox is pressed?

3) How can I easly get the checkbox value for each row?

Thanks, Alon.


Title: Re: question about checkbox in datagrid
Post by: stworthy on August 11, 2014, 08:09:58 AM
If you only want to display title on the checkbox column header, please try this:
Code:
$('#dg').datagrid('getPanel').find('.datagrid-header .datagrid-header-check').html('title').css({
fontSize:'12px',
lineHeight:'18px'
});


Title: Re: question about checkbox in datagrid
Post by: A-K on August 11, 2014, 09:28:15 AM
Thanks for the answer,
but if I also need to give it width by percentage (Added in the 1.4 version)
can it also be done this way?


Title: Re: question about checkbox in datagrid
Post by: stworthy on August 11, 2014, 06:31:00 PM
The checkbox column has fixed width, you can't change the width value to percentage. A possible way to change the width of a checkbox column is to customize its corresponding CSS style.
Code:
<style>
.datagrid-header-check,.datagrid-cell-check{
width:40px;
}
</style>


Title: Re: question about checkbox in datagrid
Post by: graveytrain on October 06, 2014, 06:07:54 PM
Would be nice to see an option for checkbox that would allow you to put the title in there instead of the check. your code above right of tells me you are going to use the word title for every checkbox in that datagrid. Works for a single, but going to have to look at how to make that work for multiple checkbox columns


Title: Re: question about checkbox in datagrid
Post by: graveytrain on October 06, 2014, 06:12:38 PM
I guess to answer my own question We could just use a combobox editor in place of the checkbox field