Swap two rows in readable grid

Hi, I have readable grid in which i am using arrow icon, so if I click on that arrow so that row should go up and upper row should come down. I can get all data items from current row, but how I will get data from previous row, So I can apply swapping conditiin

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Lead Developer
    in reply to balti
    As far as I understand, fv!identifier seems to align its own sequence (1, 2, 3, 4, ...) in the grid

    GridField is designed to work in 2 ways. 

    1. Get all the data in local variables and just show some of it in the grid. Here the paging happens on the interface level and fv!identifier's output becomes uncertain. (like you have done in the screenshot you attached)
    2. Get only a page's data from the DB and let the grid automatically query the next page, directly from the DB. In this approach, you pass directly the entire data subset in the grid. Once the grid displays data using the data subset, it will give primary keys when fv!identifier is referenced. 

    So it depends on case to case but because fv!identifier's behavior isn't 100% same every time you pass just the Data and NOT Subset, I prefer passing the entire fv!row in the whereContains. 

    And anyway, using a read-only grid and rearranging the rows isn't a good option. Because this grid isn't made for that, even if somehow it supports that. 

  • I've just tested it, and it worked exactly as you explained. I wasn't aware that fv!identifier gives the primary key when we are querying only current page's data . Thanks a lot,  . I've learned something new.