How to add borders to list view cells

  • 15 February 2022
  • 1 reply
  • 220 views

Badge +5

Topic

How to add borders to all cells in a list view

Instructions

  1. Edit the list view on K2 Designer.
  2. Add a Data Label control to the canvas.
  3. Under the General properties, enable Literal and disable Prevent XSS.
  4. Add or modify a rule for the event: "When the view executed initialized"
  5. Add a "transfer data" action.
  6. Map this value to the Data Label control added in step 2:
    <script>(function() { var setStyle = function() { $(".grid-column-header-table th, td").css({ "border-collapse": "collapse", "border": "1px solid #000000" }); $(".grid-content-table .zebra-stripes tr, td").css({ "padding": "6px", "border": "1px solid black", "vertical-align": "top", "text-align": "left" }); }; $(document).ready(function() { setStyle(); setTimeout(setStyle(), 1500); }); })();</script>​

    This script adds black borders to each cell, including the headers. This can be modified as necessary.

    19625iDB242BCF92BA2F45.png
  7. Save the view and run it.
 
 

1 reply

This works well. If you are using the list refresh method then you have to transfer again and clear the data label otherwise it does not keep the border each time you press refresh:



 

Reply