Hi Everyone:
These aren’t working to uncheck all checkboxes:
$$(‘checkboxId’).attr(‘checked’,false);
$$(‘checkboxId’).setAttr(‘checked’,false);
What to do?
Is some page in documentation reffers to such API ?
All inputs have setValue, getValue api
$$("check").setValue(1); //or "on" if you are using custom check values
Using this http://webix.com/snippet/dbf0f202
I am getting: ‘Cannot read property of undefined’
------
please be sure to add the html code
<style>
.striked{
text-decoration:line-through;
}
</style>
<div id="areaA"></div>
<div id="pager"></div>
------
var list = [];
var toolbar = {
view:"toolbar",
elements:[
{
view:"richselect", width:170, labelWidth:90,
label: 'View Pages', labelAlign:"left",
value:1, options:[
{ id:1, value:"4" },
{ id:2, value:"5" },
{ id:3, value:"6" }
],
on:{
onchange:function(){
pagerSize = this.data.text;
$$("pagerA").define("size", pagerSize);
$$("chk").refresh();
}
}
},
{
view:"richselect", width:170, id:"batchAction", labelWidth:90,
labelAlign:"left",
value:1, options:[
{ id:1, value:"" },
{ id:2, value:"red background" },
{ id:3, value:"green background" },
{ id:4, value:"blue background" },
{ id:5, value:"yellow background" }
],
on:{
onchange:function(){
//alert($$('batchAction').getText());
for(var i=0;i<arr.length-1;i++){
alert(arr[i] += ' ' + $$('batchAction').getText());
}
// uncheck items and clear list
list = [];
arr = [];
console.log(list);
$$("input.webix_table_checkbox").setValue(0);
}
}
},
{ view:"search", align:"right", placeholder:"Search by keyword", id:"searchfilter", width: 300}
]
};
var pagerData = {
id:'pagerA',
template:"{common.first()} {common.prev()} {common.pages()} {common.next()} {common.last()}",
container:"pager",
size:4,
group:5
};
var grid = {
view:"datatable",margin:50,
id:"chk",
columns:[
//checkbox column
{
id:"status",header:{ content:"masterCheckbox" }, checkValue:"on", uncheckValue:"off",template:"{common.checkbox()}", width:40,margin:100},
{ id:"title",header:"Title", width:200},
{ id:"year",header:"Year", width:200}
],
on:{
onCheck:function(id, col, status){
//var list = [];
if (status) {
list += id + ', ';
}
//else $(id, list).remove();
arr = list.split(',');
// alert(arr.length-1);
alert(arr);
console.log(list);
}
},
autoheight:true,
autowidth:true,
multiselect:true,
pager:pagerData,
select:'row',
data: [
{ id:1, title:"The Shawshank Redemption", year:1994, votes:678790, rating:9.2, rank:1, category:"Thriller"},
{ id:2, title:"The Godfather", year:1972, votes:511495, rating:9.2, rank:2, category:"Crime"},
{ id:3, title:"The Godfather: Part II", year:1974, votes:319352, rating:9.0, rank:3, category:"Crime"},
{ id:4, title:"The Good, the Bad and the Ugly", year:1966, votes:213030, rating:8.9, rank:4, category:"Western"},
{ id:5, title:"Pulp fiction", year:1994, votes:533848, rating:8.9, rank:5, category:"Crime"},
{ id:6, title:"12 Angry Men", year:1957, votes:164558, rating:8.9, rank:6, category:"Western"}
]
};
webix.ui({
container:"areaA",
rows:[ toolbar, grid]
})
All the following do not work:
$$(“checkbox”).setValue(0);
$$(“status”).setValue(0);
$$(“chk”).setValue(0);
$$(“webix_table_checkbox”).setValue(0);
$$(“input.webix_table_checkbox”).setValue(0);
How can I target all the checkboxes to set to 0?
You can’t change state of all checkboxes in the grid by one command. You will need to use eachRow operations
grid.eachRow(function(obj){ obj.checked = "off"; })
grid.refresh();
grid.eachRow(function(obj){ alert(obj); obj.checked = “off”; })
The alert gives 1,2,3,4,5… which is the row id.
But alert(obj.checked) gives undefined … so do I targeted that checkbox to change checked?
I have tried alert(obj.checkbox), alert(obj.webix_table_checkbox) … resulting in undefined.
Sorry, was a my typo, the code must be like next
grid.eachRow(function(id){ this.getItem(id).checked = “off”; })
Unfortunately, no go…still getting undefined:
grid.eachRow(function(id){ console.log(this.getItem(id).checked); this.getItem(id).checked = “off”; })
Check the next sample
http://webix.com/snippet/dfdad8dd
got it working …