</body>
</html>
<script>
mini.parse();
var tree = mini.get("treegrid1");
function ondrawcell(e) {
var tree = e.sender,
record = e.record,
column = e.column,
field = e.field,
id = record[tree.getIdField()],
funs = record.functions;
function createCheckboxs(funs) {
if (!funs) return "";
var html = "";
for (var i = 0, l = funs.length; i < l; i++) {
var fn = funs[i];
var clickFn = 'checkFunc(\'' + id + '\',\'' + fn.action + '\', this.checked)';
var checked = fn.checked ? 'checked' : '';
html += '<label class="function-item"><input onclick="' + clickFn + '" ' + checked + ' type="checkbox" name="'
+ fn.action + '" hideFocus/>' + fn.name + '</label>';
}
return html;
}
if (field == 'functions') {
e.cellHtml = createCheckboxs(funs);
}
}
function getFuns() {
var data = tree.getData();
var json = mini.encode(data);
alert(json);
}
function checkFunc(id, action, checked) {
var record = tree.getRecord(id);
if(!record) return;
var funs = record.functions;
if (!funs) return;
function getAction(action) {
for (var i = 0, l = funs.length; i < l; i++) {
var o = funs[i];
if (o.action == action) return o;
}
}
var obj = getAction(action);
if (!obj) return;
obj.checked = checked;
}