Commits

Christian Scholz  committed d103893

when loading the table the element with the UID===docview.uid is now selected.

  • Participants
  • Parent commits c5246a6

Comments (0)

Files changed (1)

File quantumnotes/static/js/searchresults.js

     
     
     
-    // update the table with data
-    update: function(data) {
+    // update the table with data, optionally give a uid to select
+    update: function(data, active_uid) {
+        active_uid=docview.uid;
+        dprint("showing uid: "+active_uid);
         var data2 = [];
+        var active_uid_index=null; // position of uid to select if active_uid is given
         for(var k=0; k<data.length; k++) {
             item = data[k];
+            dprint(item.uid);
             if (item.content) {
-                var content = item.content.slice(0,100);
+                var content = item.content.slice(0,100); //slicing might be problematic with htmlex! (TODO)
                 var content = content.replace(searchresults.htmlexer,"");
             } else {
                 var content = ""; 
                 content: content,
                 created_at: item.created_at,
             };
+            if (active_uid) {
+                if (active_uid===item.uid) {
+                    dprint("success")
+                    active_uid_index=k;
+                }
+            }
         }
-        searchresults.store.loadData(data2);    
-        searchresults.grid.selModel.clearSelections();
+        searchresults.store.loadData(data2);
+        // do we have to clear the selection or select a uid one?
+        dprint(active_uid_index);
+        if (active_uid_index!=null) {
+            dprint("ok")
+            searchresults.grid.selModel.selectRow(active_uid_index);
+        } else {
+            searchresults.grid.selModel.clearSelections();
+        }
     },
     
 }