I've been googling this all day and can't seem to find an answer. Also searched here of course, and also didn't find it, but please forgive me if I've missed the answer somewhere. I did try!
I have a YUI DataTable that contains a CheckBox field. I would like to have this box checked or unchecked based in the incoming JSON data that I'm using as the DataSource for the table. What's happening is that the checkbox is checked for all rows, and I don't know what to do to tell it to only check the box if the field value is 'true'. Here's my code as of now:
createDataTable : function (data) {
var columnDefs = [
{ key: "Well", width : 30 },
{ key: "Value", field: "ReducedValue", width : 100 },
{ key: "Hit", width : 30, formatter:YAHOO.widget.DataTable.formatCheckbox},
{ key: "Reason", field: "reason", width : 200 }
];
var dataSource = new YAHOO.util.DataSource(data);
dataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
dataSource.responseSchema = {
fields : [ "Well", "ReducedValue", "Hit", "reason" ]
};
var dataTable = new YAHOO.widget.ScrollingDataTable("data-table", columnDefs, dataSource, {height:"10em"});
$(".yui-dt table").css( { width : imageW } );
}
The 'Hit' field is the one I'm concerned with here. Incoming data with a value of 'true' for this field should have the checkbox checked, otherwise it should be unchecked.
Thanks for any help!
William