You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello friends, in a recent project I wanted to embed a query in a view for all users to be able to run it. So instead of using the provided views I wanted to properly embed the report in my views so as to use my permissions etc (the requirement was a little more complex than that but it doesn't matter).
I didn't find any docs for that so I had to research the source code and use the query_viewmodel function. So, my query detail view is similar to this:
{% extends "site_base.html" %}
{% block page_content %}
{% if params %}
<formmethod='GET'><divclass="form-inline">
{% for k, v in params.items %}
<divclass="form-group"><labelfor="{{ k }}_param" class="control-label col-sm-4">{{ k }}:</label><divclass="col-sm-7"><inputtype="text" data-param="{{ k }}" class="param form-control" name="{{ k }}_param" id="{{ k }}_param" placeholder="parameter" value="{{ v }}" /></div><divclass="col-sm-1"></div></div>
{% endfor %}
</div><inputtype='submit' class='btn btn-primary' value='Query'><ahref='{{ request.path }}' class='btn btn-secondary'>Reset</a></form>
{% endif %}
<divclass="row"><divclass="col-md-12">
{% if data %}
<tableclass='table'><thead><tr>
{% for col in headers %}
<th>{{ col }}</th>
{% endfor %}
</tr></thead><tbody>
{% for row in data %}
<tr>
{% for col in row %}
<td>{{ col }}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody></table>
{% endif %}
</div></div>
{% endblock %}
I'm not sure if this is the correct way to do it, can you please confirm. If yes, I'd recommend adding this in the documentation so it's easy for other users that want to embed queries. Also we may want to make the query_viewmodel function as part of the API so we should describe its inputs/outputs.
I can provide the PR with the change to the docs if you think it will be useful.
The text was updated successfully, but these errors were encountered:
Hello friends, in a recent project I wanted to embed a query in a view for all users to be able to run it. So instead of using the provided views I wanted to properly embed the report in my views so as to use my permissions etc (the requirement was a little more complex than that but it doesn't matter).
I didn't find any docs for that so I had to research the source code and use the
query_viewmodel
function. So, my query detail view is similar to this:Then I used a query_detail.html template like:
I'm not sure if this is the correct way to do it, can you please confirm. If yes, I'd recommend adding this in the documentation so it's easy for other users that want to embed queries. Also we may want to make the
query_viewmodel
function as part of the API so we should describe its inputs/outputs.I can provide the PR with the change to the docs if you think it will be useful.
The text was updated successfully, but these errors were encountered: