KivyMD icon indicating copy to clipboard operation
KivyMD copied to clipboard

Change mddatatable row background color at on_row_press

Open shaiful019 opened this issue 3 years ago • 2 comments

Description of the Feature

I want to change the background color of last pressed row.

Code and Logs

  from kivy.metrics import dp
  from kivy.uix.anchorlayout import AnchorLayout
  
  from kivymd.app import MDApp
  from kivymd.uix.datatables import MDDataTable
  
  
  class Example(MDApp):
      def build(self):
          layout = AnchorLayout()
          self.data_tables = MDDataTable(
              use_pagination=True,
              check=False,
              column_data=[
                  ("No.", dp(30)),
                  ("Status", dp(30)),
                  ("Signal Name", dp(60)),
                  ("Severity", dp(30)),
                  ("Stage", dp(30)),
                  ("Schedule", dp(30)),
                  ("Team Lead", dp(30))
              ],
              row_data=[
                  ("1", ("alert", [255 / 256, 165 / 256, 0, 1], "No Signal"),
                   "Astrid: NE shared managed", "Medium", "Triaged", "0:33",
                   "Chase Nguyen"),
                  ("2", ("alert-circle", [1, 0, 0, 1], "Offline"),
                   "Cosmo: prod shared ares", "Huge", "Triaged", "0:39",
                   "Brie Furman"),
                  ("3", (
                      "checkbox-marked-circle",
                      [39 / 256, 174 / 256, 96 / 256, 1],
                      "Online"), "Phoenix: prod shared lyra-lists", "Minor",
                   "Not Triaged", "3:12", "Jeremy lake"),
  
              ],
              sorted_on="Schedule",
              sorted_order="ASC",
              elevation=2
          )
          self.data_tables.bind(on_row_press=self.on_row_press)
          layout.add_widget(self.data_tables)
          return layout
  
      def on_row_press(self, instance_table, instance_row):
          '''Called when a table row is clicked.'''
  
          print(instance_table, instance_row)
  
  
  Example().run()

Versions

  • OS: Linux
  • Python: 3.9
  • Kivy: 2.0.0
  • KivyMD: 0.104.2

shaiful019 avatar Sep 21 '21 07:09 shaiful019

@shaiful019 There is no such opportunity yet.

HeaTTheatR avatar Sep 21 '21 08:09 HeaTTheatR

Any update on this? Would be great to click and change the color of a row, and hold it instead of just the highlighting on hover

Fretless14 avatar May 25 '23 13:05 Fretless14