querytable plugin’s internal key passed by caller : QueryTable (… id_key=‘hrn’ )
[myslice.git] / plugins / querytable / static / js / querytable.js
index 4cafe83..9d7bced 100644 (file)
             var query = manifold.query_store.find_analyzed_query(this.options.query_uuid);
             this.method = query.object;
 
-            var keys = manifold.metadata.get_key(this.method);
-            this.key = (keys && keys.length == 1) ? keys[0] : null;
+           // xxx beware that this.key needs to contain a key that all records will have
+           // in general query_all will return well populated records, but query
+           // returns records with only the fields displayed on startup. 
+           this.key = (this.options.id_key);
+           if (! this.key) {
+               // if not specified by caller, decide from metadata
+               var keys = manifold.metadata.get_key(this.method);
+               this.key = (keys && keys.length == 1) ? keys[0] : null;
+           }
+           if (! this.key) messages.warning("querytable.init could not kind valid key");
+
+           messages.debug("querytable: key="+this.key);
 
             /* Setup query and record handlers */
             this.listen_query(options.query_uuid);