Move row in attribute table up or down

205
2
09-07-2020 12:00 PM
MarvisKisakye1
Occasional Contributor

I am writing a button for the right click context menu of an attribute table. When the user right clicks on a row and selects the button, I would like the row they right clicked on to be moved up or down. I cannot find anything in the api that performs this functionality. I considered just deleting the selected row and recreating it at the desired position in the table but I cannot even find a method that inserts a row into the table at a specified index. It appears that any new row created is added to the end of the table. Uma Harano Wolfgang Kaiser

0 Kudos
2 Replies
RichRuh
Esri Regular Contributor

Rows in database tables are inherently unordered.  

When you view a table, you can order the rows based on the value of a particular field.  One way to implement your up/down arrow idea would be to create an "Order" field on the table and fill it in.  Then the up and down buttons would edit the rows to swap their Order values.

Whether you should do this is another matter, since this could mean a lot of database edits. Why are you trying to order the rows?

--Rich

0 Kudos
MarvisKisakye1
Occasional Contributor

Rich Ruh The user is tasked with arranging rows (by moving them up or down) in an order that matches what they see on a structural engineering plan. We would them have code that populates a field based on the order that the user has set up and assign new relevant other data based on that order. The idea is to ease data creation and ensure accuracy since all they have to do is arrange the rows in the same order as they see on the sheet..

If there are no other options I guess I could use the idea you provided; to use the up or down commands to populate an order field and continuously sort it accordingly.

0 Kudos