Skip to content
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

To link a page for a particular cell for server side program #1

Open
DinakaranP opened this issue Jul 27, 2022 · 5 comments
Open

To link a page for a particular cell for server side program #1

DinakaranP opened this issue Jul 27, 2022 · 5 comments
Labels
question Further information is requested

Comments

@DinakaranP
Copy link

Hi @miguelgrinberg
Thank you so much for the wonderful Documentation written on flask Tabels
Quick help
I need to create a hyperlink based on the cell value to another table in the server side programme
I tried using the basic_tabel.py and tried to link to another page which looks something like this

  <td><a href="{{'/food_id/%s'%main.Food_id}}">{{ main.Food_id }}</a></td>
@miguelgrinberg
Copy link
Owner

Are you asking me how to do this? The <td> element that you are showing looks fine to me, without any context I really don't have any comments about it.

@miguelgrinberg miguelgrinberg added the question Further information is requested label Jul 27, 2022
@DinakaranP
Copy link
Author

In the server-side program is server_tabel.html, we are not using jinja to render table elements instead we use the ajax method to render table elements
For the server-side program, I need to hyperlink using the table elements to other tables

@miguelgrinberg
Copy link
Owner

I don't remember if this works with datatables.js or not, but have you tried returning the <a> element in the ajax call?

@DinakaranP
Copy link
Author

    $(document).ready(function () {
      $('#data').DataTable({
        ajax: '/api/data',
        serverSide: true,
        columns: [
          {data: 'name',
          "render":function(data,type,row,meta)
          {
          if(type === 'display')

          {
           data='<a href="'+data+'">' + data + '<a>';
          }
          return data;
          }
          },
          {data: 'age'},
          {data: 'address', orderable: false},
          {data: 'phone', orderable: false},
          {data: 'email'}
        ],
      });
    });
  </script>

I got this snippet from one of the stack overflow link
As I am new to javascript need some help in creating the route
/something/

@miguelgrinberg
Copy link
Owner

@DinakaranP I was suggesting you return the HTML that you want to render from the server, which might be easier if you are more experienced with Python. Unfortunately I don't use datatables.js anymore and I don't remember its particular details. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants