Hi,
I have a grid that scrolls horizontally and each column represent a day and row is a type. I use multiple IGGridViewCell based classes to achive that. The datasourcehelper CreateCell decides based on a row what class to use. ALl works great.
Now I want to replace my old implementation of editable cells with built-in feature that is available based on ColumDefinitions, but I am a little puzzled on how to do that using IGGridViewColumnDefinition since I do not have columns (it is just cell path that is being used to lookup the value while the grid is scrolled horizontally).
Am I confused for a reason or I am missing something?
Thank you
Mark
Steve,
Thank you, I attempted very similar approach as well ;~)
The reason that I am going through this conversion is because at the moment I am using my own EditView field management but have problem that
after rotation and/or scrolling the cells do not get tap events anymore or do but after quite a few clicking.
Same happening here as well, just try the following steps:
take new uploaded code and run it
1. click on PT02. you will see cell is going to edit mode3. now scroll all the way to the right4.click on PT9 - cell again it is going to edit mode5. dismiss the keyboard which would turn off edit mode6. now do not scroll and just try click on PT8 and get it into edit mode - not possible.
Hey Mark,
Yup, my bad i should have posted that code too.
Similar approach, just want to make sure to implement: DidEndDisplayingCell
Here is the full code, with the handleEdit updated as well.
[Export("HandleEdit:")] private void HandleEdit(UITapGestureRecognizer gestureRecognizer) { gestureRecognizer.Reset(); var cell = gestureRecognizer.View as IGGridViewCell; if (cell == null) return; if (_editCell != null && cell != _editCell) { IGCellPath lastPath = this.NormalizePath (_editCell.Path); var lastCol = this.ColumnDefinitions.GetItem<NSObject>(lastPath.ColumnIndex) as IGGridViewColumnDefinition; lastCol.RemoveEditor (_editCell.GridView, _editCell.Path, this, true, true); } _editCell = cell; IGCellPath normPath = this.NormalizePath (cell.Path); var colDef = this.ColumnDefinitions.GetItem<NSObject>(normPath.ColumnIndex) as IGGridViewColumnDefinition; colDef.DisplayEditor (cell.GridView, cell.Path, this); } public override void DidEndDisplayingCell (IGGridView gridView, IGGridViewCell cell, IGCellPath path) { if (cell == _editCell) { IGCellPath normPath = this.NormalizePath (cell.Path); var colDef = this.ColumnDefinitions.GetItem<NSObject>(normPath.ColumnIndex) as IGGridViewColumnDefinition; colDef.RemoveEditor (cell.GridView, cell.Path, this, false, false); } }
Let me know if that works.
-SteveZ
Thank you - that helps.
Since DisplayEditor is invoked now manually how do I handle RemoveEditor override?
Thanks for the sample, i saw it this morning.
So, b/c you're not actually providing the DSH with an actual Array of data, you're kind of bypassing some of the setup process thats happening internally. It's not a big deal though, we'll just have to make a few tweaks.
1. Whenever you're customizing how columns/rows are working, you'll want to override NormalizePath/DenormalizePath. These methods basically take the path where the cell is going to render, and converts it back to how the data is actually represented internally. In your case, its simply a matter of swapping the rows and columns:
public override IGCellPath NormalizePath (IGCellPath path) { return new IGCellPath (path.ColumnIndex, path.SectionIndex, path.RowIndex); }
So, now in createCell, you would actually resolve your column definition like this:
public override IGGridViewCell CreateCell(IGGridView gridView, IGCellPath path) { IGCellPath normPath = this.NormalizePath (path); var colDef = this.ColumnDefinitions.GetItem<NSObject>(normPath.ColumnIndex) as IGGridViewColumnDefinition;
Note how we're using the normPath, and using the columnIndex.
Now, the next thing that isn't working is calling beginEditing. That's because the actual columns internally were never setup. This usually happens during InvalidateData, but since you aren't binding an array of data, that will never happen. No big deal though, b/c you can handle this yourself. As all its doing is looking up the column and calling displayEditor on it.
[Export("HandleEdit:")] private void HandleEdit(UITapGestureRecognizer gestureRecognizer) { gestureRecognizer.Reset(); var cell = gestureRecognizer.View as IGGridViewCell; if (cell == null) return; IGCellPath normPath = this.NormalizePath (cell.Path); var colDef = this.ColumnDefinitions.GetItem<NSObject>(normPath.ColumnIndex) as IGGridViewColumnDefinition; colDef.DisplayEditor (cell.GridView, cell.Path, this); }
Hope this helps!