one specific page. we have a page where users view PDFs of SOPs (standard operating procedures). this page has a grid with somewhere from 5-60 rows, one per PDF. it's a LABKEY.ext.EditorGridPanel. i used this instead of the labkey grid b/c it's loaded from a store filtered on user ID.
i'd like to create a mechanism such that we can record when a user downloads each of their SOPs. is that possible?
if there's no way to listen for file-download, then the next best solution i can think of is to create a 'mark read' button, but this is less automatic. |
Hi Ben,
There's no specific support for this, but it sound like the best approach for this particular case might be to swap out a custom column renderer into your grid. You could replace the default URL with an onclick handler that inserts a record into a list (or other table) and then opens the PDF in the browser.
Thanks,
Josh |
Hi Ben,
There's some sample code in the documentation for LABKEY.ext.EditorGridPanel that shows how you can replace a column's renderer. You should be able to use it as a base to swap in a renderer that builds up HTML that includes an onclick handler that calls a function that inserts the record into the list and then lets the user view the content they requested.
Thanks,
Josh |
ok, i've got a start on this and have a few questions:
1. according to the ext documentation, I should be able to specify a custom columnModel with an EditorGridPanel:
var sopGrid = new LABKEY.ext.EditorGridPanel({
store: new LABKEY.ext.Store({..})
,renderTo: 'sopDiv'
,width: 1000
,cm: new Ext.grid.ColumnModel({..})
});
When the LABKEY.ext.EditorGridPanel first renders, my custom colModel is applied, but as soon as the Labkey store loads (and rows are populated) my custom colModel gets overridden by the default labkey behavior. Is there any way to define a custom colModel beforehand (in the store or something?), or do I need to add a handler to alter the colModel using the 'colmodelcustomize' event?
2. following the example in the labkey documentation for LABKEY.ext.EditorGridPanel, I can add a custom renderer. however, what's the right approach to add an onClick handler? following the example, we have something like:
function pdfRenderer(data, cellMetaData, record, rowIndex, colIndex, store)
{
//run the existing renderer
var theField = _basePdfRenderer(data, cellMetaData, record, rowIndex, colIndex, store);
return theField;
}
in the above example, the default renderer produces a string with the URL for the file and display icon. what's the right point to manipulate this to add the handler? should I just discard the default renderer and build the URL / display icon HTML myself? can i somehow hook into this to add the handler in another way?
Hope this makes sense. Thanks for the help. |