QueryWebPart showRecordSelectors and sql options with dataRegion.getSelected/getChecked | Anthony Corbett | 2013-04-05 09:41 |
Status: Closed | ||
I just wanted to post a solution to populating DataRegion selector checkbox values when using QWP with the sql option so that dataRegion.getSelected() and dataRegion.getChecked() work. If there is a better solution please reply! If you use the QWP with the sql option but want the allow the user to select rows to take further action it is necessary to specify table metadata in order to get the selector checkboxes to be populated with a value, this doesn't happen by default (as there is no easier what to specify the pk when using the sql option than using table metadata). You must add the following to the query config in order to get the selector values to populate: metadata: { type: 'xml', value: '<tables xmlns="http://labkey.org/data/xml"><table tableName="SQLTempTable" tableDbType="NOT_IN_DB"><columns><column columnName="RowId"><columnTitle>Material ID</columnTitle><isHidden>true</isHidden><isKeyField>true</isKeyField></column></columns><pkColumnName>RowId</pkColumnName></table></tables>' } This directs the QueryDefintion and DataRegion to see the RowId column as the primary key for this sql query. You can change the name of the column and in my case I wanted it hidden. Without the table metadata the selector looks like this: <input type="checkbox" onclick="LABKEY.DataRegions["aqwp3"].selectRow(this);" value="" name=".select" title="Select/unselect row"> After adding it the rowId is populated in the value attribute and dataRegion.getSelected() and dataRegion.getChecked() work again: <input type="checkbox" onclick="LABKEY.DataRegions["aqwp3"].selectRow(this);" value="117220" name=".select" title="Select/unselect row"> If there is a better way to do this please let me/everyone know! Cheers, Anthony Corbett |
||