|
Jon (LabKey DevOps) responded: |
2017-09-14 15:46 |
Hi Leo,
Let me get this confirmed, but I think it does.
Although the doc doesn't mention it here:
https://www.labkey.org/download/clientapi_docs/javascript-api/symbols/LABKEY.ext.Store.html
I am seeing config.parameters listed here:
https://www.labkey.org/download/clientapi_docs/javascript-api/symbols/src/Z__teamcity_work_d503835eb40d8d2f_server_api_webapp_clientapi_ext3_Store.js.html
Specifically in this part of the code:
145 if (config.parameters)
146 {
147 for (var n in config.parameters)
148 baseParams["query.param." + n] = config.parameters[n];
149 }
150
And that appears to match up to LABKEY.Query:
https://www.labkey.org/download/clientapi_docs/javascript-api/symbols/LABKEY.Query.html#.selectRows
282 if (config.parameters)
283 {
284 for (var n in config.parameters)
285 {
286 if (config.parameters.hasOwnProperty(n))
287 {
288 qsParams["query.param." + n] = config.parameters[n];
289 }
290 }
291 }
And the information here showing the URL request when using parameters would be "query.param.FIELDNAME":
https://www.labkey.org/Documentation/wiki-page.view?name=paramsql
So logically, using the example from the JS API documentation, using parameters would look something like this then:
var _store = new LABKEY.ext.Store({
schemaName: 'core',
queryName: 'Users',
columns: "DisplayName, Phone",
autoLoad: true,
parameters: {'FieldName': 'Value', '2ndFieldName': 'Value'}
});
Please feel free to give that a try while I get this confirmed.
Thank you for your patience.
Regards,
Jon |
|
Jon (LabKey DevOps) responded: |
2017-09-14 16:25 |
Hi Leo,
I got confirmation that it does support it, so you should be in good shape.
Let us know if you have any additional questions.
Regards,
Jon |
|
Leo Dashevskiy responded: |
2017-09-14 16:31 |
This does not work for us:
var chk = new LABKEY.ext.Store({ schemaName: 'study', queryName: 'IRP_all', parameters: { 'pids': 'SUB114450.80'}, autoLoad: true }) |
|
Jon (LabKey DevOps) responded: |
2017-09-14 18:22 |
Hi Leo,
Are you getting an error or is it just not working?
Does the code work without the parameters option?
I'll see about trying to construct a test on my end, but it should allow a parameter.
Regards,
Jon |
|
Leo Dashevskiy responded: |
2017-09-14 20:39 |
Jon,
We get a JSON response error about the parameter not being provided:
{"exception":"Parameter not provided: pids","exceptionClass":"org.labkey.api.query.QueryService$NamedParameterNotProvided","stackTrace":["org.labkey.query.QueryServiceImpl.validateNamedParameters(QueryServiceImpl.java:2197)","org.labkey.api.data.TableSelector$TableSqlFactory.getSql(TableSelector.java:517)","org.labkey.api.data.SqlExecutingSelector$ExecutingResultSetFactory.getResultSet(SqlExecutingSelector.java:317)","org.labkey.api.data.BaseSelector.handleResultSet(BaseSelector.java:261)","org.labkey.api.data.SqlExecutingSelector.getResultSet(SqlExecutingSelector.java:147)","org.labkey.api.data.TableSelector.getResults(TableSelector.java:302)","org.labkey.api.data.TableSelector.lambda$getResultsAsync$1(TableSelector.java:313)","org.labkey.api.data.AsyncQueryRequest$1.run(AsyncQueryRequest.java:108)","java.lang.Thread.run(Thread.java:748)"]}
It does not work without the parameter, naturally, since the query requires a parameter.
-Leo |
|
Leo Dashevskiy responded: |
2017-09-14 20:57 |
More details:
Line 197 of Store.js
LABKEY.ext.Store.superclass.constructor.call(this, {
reader: new LABKEY.ext.ExtendedJsonReader(),
proxy: this.proxy ||
new Ext.data.HttpProxy(new Ext.data.Connection({
method: 'POST',
url: (config.sql ? LABKEY.ActionURL.buildURL("query", "executeSql", config.containerPath, qsParams)
: LABKEY.ActionURL.buildURL("query", "selectRows", config.containerPath)),
listeners: {
beforerequest: {fn: this.onBeforeRequest, scope: this}
},
timeout: Ext.Ajax.timeout
})),
baseParams: baseParams,
autoLoad: false
});
Where "url" evaluates to:
(config.sql ? LABKEY.ActionURL.buildURL("query", "executeSql", config.containerPath, qsParams)
: LABKEY.ActionURL.buildURL("query", "selectRows", config.containerPath))
"/query/Studies/SDY80/selectRows.view"
and
JSON.stringify(baseParams)
"{"schemaName":"study","query.queryName":"IRP_all","query.param.pids":"SUB114450.80","apiVersion":9.1}"
So that fails per the error above... |
|
Jon (LabKey DevOps) responded: |
2017-09-18 23:20 |
Hi Leo,
I did a basic test using the code example here:
https://www.labkey.org/download/clientapi_docs/javascript-api/symbols/LABKEY.ext.Store.html
And the parameterized queries doc here:
https://www.labkey.org/Documentation/wiki-page.view?name=paramsql
Using the Physical Exam dataset from our demo study, I created the following wiki:
<div id="div1"/>
<script type="text/javascript">
// This sample code uses LABKEY.ext.Store to hold data from the server's Users table.
// Ext.grid.EditorGridPanel provides a user interface for updating the Phone column.
// On pressing the 'Submit' button, any changes made in the grid are submitted to the server.
var _store = new LABKEY.ext.Store({
schemaName: 'study',
queryName: 'ParameterizedQuery',
columns: 'ParticipantId,date,Temp_C,Weight_kg',
parameters: {'MinTemp': '37', 'MinWeight': '100'},
autoLoad: true
});
var _grid = new Ext.grid.EditorGridPanel({
title: 'Param Store Test',
store: _store,
renderTo: 'div1',
autoHeight: true,
columnLines: true,
viewConfig: {
forceFit: true
},
colModel: new Ext.grid.ColumnModel({
columns: [{
header: 'Participant Id',
dataIndex: 'ParticipantId',
hidden: false,
width: 10
}, {
header: 'Date',
dataIndex: 'date',
hidden: false,
sortable: true,
width: 10,
editor: new Ext.form.TextField()
}, {
header: 'Temperature',
dataIndex: 'Temp_C',
hidden: false,
width: 10
}, {
header: 'Weight',
dataIndex: 'Weight_kg',
hidden: false,
width: 10
}]
})
});
</script>
Now, although I didn't get the error like you did, I did notice that the parameters were not showing up in the POST to the query-selectRows.view endpoint when running the Google JConsole debugger.
I'll get a bug written up on this to get this investigated further.
Regards,
Jon |
|
Jon (LabKey DevOps) responded: |
2017-09-18 23:27 |
|
|
Henrich, Evan responded: |
2017-09-19 12:15 |
|
|
Jon (LabKey DevOps) responded: |
2017-09-19 12:22 |
Hi Evan,
The bug was fixed just today in r53845, which is in the trunk build and will eventually get into 17.3
Are you using the trunk build from source or are you using an older version of LabKey? If you're using an older version of LabKey, then you will still have an issue until you update to 17.3 when it is out in November or you would have to obtain a trunk build that includes the fix that was put in earlier.
Regards,
Jon |
|
Henrich, Evan responded: |
2017-09-19 13:02 |
Jon,
Thanks for the update. We had updated our build yesterday, so I thought perhaps it was in that one. I've just requested a new build from Angelica so we will give it another shot after getting that one set up.
E |
|
Jon (LabKey DevOps) responded: |
2017-09-19 13:09 |
Hi Evan,
I'll make sure we get that pushed out to you once it's available. We're currently running trunk on r53840 and the revision hasn't hit yet, but should by tonight and the build will be available by tomorrow morning at the earliest.
Regards,
Jon |
|
Jon (LabKey DevOps) responded: |
2017-09-29 14:16 |
Hi Everyone,
I've managed to successfully test this and confirmed locally that the Javascript API does work now with the LABKEY.Ext.Store via my test above.
Please update your version of Trunk and you should see the changes take effect. These changes will be available in the upcoming 17.3 Release in mid-November as well.
Regards,
Jon |
|
|
|