I checked some rows to delete of my mddattatable but when I clicked at next page of the paginator the mddatatable.get_row_checks()=[] even when I checked some rows can any one help please

I want to get the checked rows to delete

1

There are 1 best solutions below

0
maiada On

I have found the solution

 def remove_rows(self , *srgs):
    #self.get_checked_list_nums(self.data_tables)
    def deselect_rows(*args):
            self.data_tables.table_data.select_all("normal")
    if len(self.data_tables.table_data.current_selection_check)==0:
        self.show_dialog("Please Check At least One Row")
    else:
        pages = self.data_tables.table_data.current_selection_check
        self.checked_ids= []
        self.checked_rows=[]          
        for page in pages.keys():
            for row_index in pages[page]:
                cols_num = len(self.data_tables.column_data)
                index = int(row_index/cols_num) +self.data_tables.rows_num*page
                self.checked_ids.append(self.data_tables.row_data[index][0])
                self.checked_rows.append(self.data_tables.row_data[index])
                #self.data_tables.remove_row(self.checked_rows)
        print("delete rows - self.checked_ids ==> ", self.checked_ids)
        print("delete rows - self.checked_rows ==> ", self.checked_rows)
        for row in self.checked_rows:
            self.data_tables.row_data.remove(row)
        for id in self.checked_ids:
            delete_api(id) #function that use alchemy to delete rows by id
        
        print("delete rows - self.checked_rows ==> ", self.checked_rows)
        Clock.schedule_once(deselect_rows)