I want to insert row at specific location in datagrid2

0
I have and data grid and all rows are editable inline and when object is created a blank object is created and row is inserted at top. What I want is I want to inster it at specifc location basically after selcted row.
asked
2 answers
0

Rajan,

You will need to use a microflow for this, no the out of the box Create functionality.


Create a microflow that accepts a parameter of the object type in your Grid. When the microflow executes, create a new object and set an attribute of that object to an appropriate value so that the new object appears in the grid after the selected row.


You may need to change the attribute for objects after the selected row in order for the rows to appear in the order you want them to.


Hope that helps,

Mike

answered
0

Is your datagrid sorted? If so by what attribute? Also how many rows do you have? I would suggest adding an attribute OrderIndex, then run a microflow to patch all your rows so they are ordered properly. Use an index of multiples of 10 (10, 20, 30, ...) instead of 1 (1, 2, 3...). That way when you create a new row you can just set that attribute to be 1 after the previous OrderIndex. You'll need a microflow or nanoflow for that though.


For example:


  1. You have a table of Tasks. It is orderd by OrderIndex.
  2. Task3 has an OrderIndex of 30 and shows up third on the list.
  3. When you select that Task3 and click New Task, it would trigger a microflow or nanoflow that passes in the selected Task3 as a parameter.
  4. You then read the OrderIndex off of that selected Task3 (30), create a new task with an OrderIndex of 31. So when you commit and refresh table, it will show up right after that other one.


At some point you may want to normalize it or do that on a scheduled task so that it goes through your entire data set and resets the current order to indexes of 10 again so that sample new task would now have an index of 40 and everything after would go 50, 60, 70, etc. You wouldn't want to do that on the initial new index creation though because that could be potentially really slow if you have a lot of rows. Better to do as a batch in the background at the end of the day or something like that.


Hope that helps!

answered