-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R data.table demo #84
base: main
Are you sure you want to change the base?
Conversation
I don't have R on my machine. Here's a working Python version: from h2o_wave import main, app, Q, ui
table = '''
<table id='myTable'>
<thead>
<tr>
<th>Name</th>
<th>Position</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tiger Nixon</td>
<td>System Architect</td>
</tr>
<tr>
<td>Garrett Winters</td>
<td>Accountant</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
</tr>
</tfoot>
</table>
'''
script = '''
var t = setInterval(() => {
if ($().DataTable) {
$('#myTable').DataTable();
clearInterval(t);
}
}, 250);
'''
@app('/demo')
async def serve(q: Q):
if not q.client.initialized:
q.page['meta'] = ui.meta_card(
box='',
scripts=[
ui.script(path='https://code.jquery.com/jquery-1.12.4.min.js'),
ui.script(path='https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js')
],
script=ui.inline_script(
content=script,
requires=['jQuery'],
targets=['myTable']
)
)
q.page['table'] = ui.markup_card(
box='1 1 12 10',
title='Table',
content=table,
)
q.client.initialized = True
await q.page.save() |
requires='jQuery', targets='myTable'
See: @ashrith |
Fix -> #85 |
added to list
@lo5 Do I need the
|
Yes, you'll need the entire script, because datatable is a jQuery extension, not a separate module, and that script is the only reliable way to detect if it has been downloaded and available. This is also why we had to add jQuery to your original script. |
@lo5 @ashrith In 525ee05 I tried adding the CSS to get the table to look like the one on the https://datatables.net homepage; i.e. with the lines, alternate shaded rows, and the arrows on the column headings. But this attempt didn't have any effect; i.e. I see the table but it looks like this: I see this in Chrome console so I guess CSS should not be passed to But then I don't know where to put the CSS file. I looked and searched for arguments and/or function names in |
We don't have an API to add CSS files, but is trivial to implement. |
Draft PR for @lo5 to view.