omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    How to select all items in a table view? (iOS python ui on Pythonista)

    Pythonista
    noob pythonista tableview ios
    4
    8
    5963
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • BobPeltonUK
      BobPeltonUK last edited by

      I tried really everything but no success,also tried to look for it in here and google but Nothing !

      Cycling all items and append them in the selected rows list has no effect!
      Thanks in advance.

      1 Reply Last reply Reply Quote 0
      • BobPeltonUK
        BobPeltonUK last edited by

        Here’s the def:

        def SelezionaTutti(sender):
        	chkbox=sender.superview['SwitchSelezionaTutti']
        	listview=sender.superview['DatiDaExcel']
        	if chkbox.value==True:
        		for i in listview.data_source.items:
        			listview.selected_rows.append(i)
        	elif chkbox.value==False:
        		listview.selectedindex=-1
        	print(listview.selected_rows)```
        1 Reply Last reply Reply Quote 0
        • brumm
          brumm last edited by

          TableView.selected_rows needs a sequence of selected rows, each as a 2-tuple (section, row). try (0, row)

          1 Reply Last reply Reply Quote 1
          • BobPeltonUK
            BobPeltonUK last edited by

            Where do I put the tuple? It’s ok to iterate on datasource.items to select them?

            1 Reply Last reply Reply Quote 0
            • brumm
              brumm last edited by

              length = len(self.view['tableview1'].data_source.items)
              r = []
              for i in range(1, length):
                  t = tuple([0, i])
                  r.append(t)
                  self.view['tableview1'].selected_rows = r
              
              1 Reply Last reply Reply Quote 1
              • BobPeltonUK
                BobPeltonUK last edited by

                Perfect IT WORKS!!
                now the problem is how to deselect all :D but i can get to it!

                1 Reply Last reply Reply Quote 0
                • Gcarver
                  Gcarver last edited by

                  I was having an issue setting TableView.selected_rows. I discovered that my problem was assignment doesn't replace the current list, but adds to it. So setting it to [] will not clear the current selections and adding say [(0, 1)] will simply add row 1 to the already selected rows.
                  The only way I could find to clear the current selections to [] was calling TableView.reload_data() before setting selected_rows.

                  1 Reply Last reply Reply Quote 0
                  • JonB
                    JonB last edited by

                    Have you tried using append and clear or del, rather than setting to a new empty list?

                    I.e
                    tableview.selected_rows.append((0,1))

                    And either

                    tableview.selected_rows.clear()
                    

                    Or
                    del tableview.selected_rows[:]

                    To clear it.

                    I can imagine a scenario where the selected_rows object is linked in some way to the native iOS list, and so just setting to a new object doesn't actually clear the old one..

                    1 Reply Last reply Reply Quote 0
                    • First post
                      Last post
                    Powered by NodeBB Forums | Contributors