EasyUI Forum
May 14, 2021, 01:23:09 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: Datalist Checkbox OnChange  (Read 295 times)
jwilliquor
Newbie
*
Posts: 15


View Profile
« on: February 22, 2021, 12:20:39 PM »

How do i add an onChange handler for the checkbox on a datalist like this.

   $(function(){
      $('#dl').datalist({
         data: data,
         selectOnCheck: false,
         textField: 'item',
         valueField: 'value'
      });
   })
   

Thanks
Justin
Logged
jarry
Administrator
Hero Member
*****
Posts: 1978


View Profile Email
« Reply #1 on: February 23, 2021, 10:39:12 PM »

Please listen to the 'onCheck' event that will fire while checking a row.
Code:
$('#dl').datalist({
data: data,
selectOnCheck: false,
textField: 'item',
valueField: 'value',
selectOnCheck: false,
onCheck: function(index,row){
console.log(row)
}
})
Logged
jwilliquor
Newbie
*
Posts: 15


View Profile
« Reply #2 on: February 26, 2021, 08:48:06 AM »

This onCheck is helpful but does not handle when the checkbox get's unchecked. Is there an event for that as well?

Thanks
Justin
Logged
jarry
Administrator
Hero Member
*****
Posts: 1978


View Profile Email
« Reply #3 on: March 02, 2021, 12:07:55 AM »

The 'onCheck' and 'onUncheck' events can be used together on the 'datalist' component.
Code:
$('#dl').datalist({
data: data,
selectOnCheck: false,
textField: 'text',
valueField: 'value',
selectOnCheck: false,
onCheck: function(index,row){
console.log('check:'+row.text)
},
onUncheck: function(index,row){
console.log('uncheck:'+row.text)
}
})
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!