EasyUI Forum
May 09, 2024, 04:43:57 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: question about checkbox in datagrid  (Read 14522 times)
A-K
Full Member
***
Posts: 122


View Profile WWW
« 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.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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'
});
Logged
A-K
Full Member
***
Posts: 122


View Profile WWW
« Reply #2 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?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 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>
Logged
graveytrain
Newbie
*
Posts: 17


View Profile Email
« Reply #4 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
Logged
graveytrain
Newbie
*
Posts: 17


View Profile Email
« Reply #5 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
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!