I have a flask application that makes a call to my API to pull down some records. I then pass the json response to json2html, then to datatables to create a table. I plan on creating a button on my table with row select option.
My question is, can I use the data on my table to populate a form on another page? Effectively I want to be able to select the row, click update button which takes me to a form page with the form values populated from the row values. So if click row 1, and my form page with be populated,
id = 6a3d7026-43f3-67zt-9211-99dfc6fee82e
name = test
description = test
number = 20934120
....some other fields not from the table
I am not sure how I can achieve this without a database. Not looking for a full solution just some pointers on the best methods or some good documentation. Thanks
example response
{'count': 2, 'total': 2,
'data': [
{'id': '6a3d7026-43f3-67zt-9211-99dfc6fee82e',
'name': 'test',
'properties': {'Description#en': 'test', 'Number#en': '20934120'},
{'id': '6a3d7026-43f3-67zt-9211-99hdttbhh4ed',
'name': 'test',
'properties': {'Description#en': 'test', 'Number#en': '20934121'}}],
inside app.py
....REQUEST
response = requests.request("GET", url, headers=headers, data=payload)
data = json.loads(response.text)
output = json2html.convert(json = data, table_attributes="id=\"table1\" class=\"table1\")
return render_template("update.html", data=data, output=output)
inside update.html
{{output|safe}}
<script>
$(document).ready(function() {
$('#table1').DataTable( {
"searching": false,
dom: 'Bfrtip',
buttons: [
{
text: 'Update',
action: function ( e, dt, node, config ) {
alert( 'This is my button' );
}
}
]
} );
} );
</script>