Hey @mark.breuss - I’ve managed to get this working now with items pulled from my server:
- Headerlist is a list of rows in a table
- Itemlist is a list of key, value pairs that are linked to each row
As a result, the grid now displays like this:
Representing the contents of the Global_Pushes table, which looks like this:
What I’m now trying to do is update the server table when the item is moved from one column to another. I can see the code:
def get_item_from_muuri(self,muuri_element):
item_id = muuri_element.getElement().getAttribute('item_id')
if not item_id in self.item_id_items:
print('item uid is not in items',item_id,self.item_id_items)
return self.item_id_items.get(item_id)
Pulls out the details of the item that has been moved, and I’m trying to get the details of the column that the item landed in (so I can find the item in the table and update which row it’s linked to).
I updated the create_col function and I think it’s adding a UID to the column, too:
def create_col(self,grid_column,items):
#create new muuri grid column
from anvil.js.window import Muuri
'''trying to add a column id '''
col_id = self.get_uid()
js.get_dom_node(grid_column).setAttribute("col_id", col_id)
However, I can’t seem to find a way to find the col_id using Muuri:
def drag_resease_end(self,muuri_element):
item = self.get_item_from_muuri(muuri_element)
'''Add a column finding code line'''
col = self.get_column_from_muuri(muuri_element)
self.raise_event('items_changed',item=item)
def get_column_from_muuri(self, muuri_element):
'''get the col_id, too'''
muuri_col = self.grid_panel
col_id = muuri_element.getElement().getAttribute('col_id')
With the last function returning “None”.
How can I identify the column that the item was dropped into, so I can pass that back to the server?
Here’s where I’ve been playing with this code:
https://anvil.works/build#clone:QCTVZS4RTZNZ7XVU=P7OVF4MUPHHWDGI3KSKOYYQZ