EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: jwilliquor on February 22, 2021, 12:20:39 PM



Title: Datalist Checkbox OnChange
Post by: jwilliquor 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


Title: Re: Datalist Checkbox OnChange
Post by: jarry 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)
}
})


Title: Re: Datalist Checkbox OnChange
Post by: jwilliquor 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


Title: Re: Datalist Checkbox OnChange
Post by: jarry 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)
}
})