-
- var id;
- /* The function accepts both records and their key */
- switch (manifold.get_type(record)) {
- case TYPE_VALUE:
- id = record;
- break;
- case TYPE_RECORD:
- /* XXX Test the key before ? */
- id = record[this.key];
- break;
- default:
- throw "Not implemented";
- break;
- }
-
-
- if (id === undefined) {
- messages.warning("querytable.set_checkbox record has no id to figure which line to tick");
- return;
- }
- // PB TO CHECK THE RIGHT CHECKBOXES IS HERE... flat_id using \ in the key
- // need to use escape_id when creating the id of the checkboxes
- var checkbox_id = this.flat_id(this.id('checkbox', id));
- // function escape_id(myid) is defined in portal/static/js/common.functions.js
- checkbox_id = escape_id(checkbox_id);
- // As we are using [id="x"] syntax, we need to remove the # in the checkbox_id
- checkbox_id = checkbox_id.replace("#","");
- // using dataTables's $ to search also in nodes that are not currently displayed
- var element = this.table.$('[id="' + checkbox_id + '"]');
- if (debug)
- messages.debug("set_checkbox checked=" + checked
- + " id=" + checkbox_id + " matches=" + element.length);
- element.attr('checked', checked);
- },
+ var init_id = record[this.init_key];
+ if (debug) messages.debug("querytable.set_checkbox_from_record, init_id="+init_id);
+ // using table.$ to search inside elements that are not visible
+ var element = this.table.$('[init_id="'+init_id+'"]');
+ element.attr('checked',checked);
+ },
+
+ // id relates to canonical_key
+ set_checkbox_from_data: function (id, checked) {
+ if (checked === undefined) checked = true;
+ if (debug) messages.debug("querytable.set_checkbox_from_data, id="+id);
+ // using table.$ to search inside elements that are not visible
+ var element = this.table.$("[id='"+id+"']");
+ element.attr('checked',checked);
+ },