Hi,
I am trying to add a new row to xamgrid, when the grid is not sorted the row should be added to the top of the grid, but when sorted, the row takes its place between the other rows.
I have some work to do with the row before saving it, so i use the handler (RowAdded) to do it.
Problem : in row added, the row that i will be editing, has the index 0, so if the grid is sorted, and the newly added row doesn't take the index 0, i will be editing another row in (RowAdded)
how to edit the newly added row in the grid regardless to its index in the grid ???
Well then you would need to apply a sort that would keep your record first. Since you are adding a column to your grid to show your Icon, you could listen to the event raised when the grid is sorted. Check the sorted columns collection, and ensure that your "IsAdded" column is always in the collection and first in the collection.
This is how my grid looks like,
when i add a new record, i fill in the blanks of the first record (where the sign "+" exists)
and then i press (Enter) the record i filled will be added to the grid, view the below:
This record is added, but not saved in the database yet,
so i press save, to save it using the context of Entity Framework, so the grid takes automatically the row with index 0 and saves it.
but in my case, when i sort the grid, the row added has not the index 0 anymore, it may be added to index 4 (depending on the sort result) ... when attempting to save the index 0, i am saving wrong data.. and the real record has not been saved.
plz help.
I am not sure what that last question was. When the XamGrid is entering data into the underlying collection, it will just add it at the end of the collection. If there is a sort applied to the data via our datamanager, then when we detect a row is added the sort is reapplied, so the row is going to be seen in it's new location.
Now are you trying to put the row that was just added into the collection into edit mode? Is that what you are trying to do? Or are you just trying to change a value on the data object?