Thymeleaf: clickable row

泪湿孤枕 提交于 2019-12-05 05:56:44

The least problematic way to do this is using javascript to create each row clickable.

for e.g.

$("#yourtablename tr").click(function() {
            //do more javascript code to meet your needs
      });

Personally i would attach a href to one of the tds then do something like below:

$("#yourtablename tr").click(function() {
                window.location = $(this).find('td:eq(5)').attr("href");
          });

Hope that helps

I had to solve pretty similar problem with Tymeleaf, and I've also been needed to pass request parameter from item to the url, so I solved like this:

<tr th:each="item : ${itmes}" style="cursor: pointer"
     th:onclick="'javascript:rowClicked(\'' + ${item.someField} + '\');'">
    ...
    <td>Some data</td>
    ...
</tr>

then include somehow the script:

<script>
    function rowClicked(value) {
        location.href = "/myurl?param=" + value;
    }
</script>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!