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
Hey Mark,
So it sounds like you're just flipping your data, right?
So every item in the array of your data represents a Column, instead of a row?
If so, that sounds like you should just use the IGGridViewSingleRowSingleFieldDataSourceHelper. Basically this DatasourceHelper flips your data automatically.
The singleRow datasource helper takes a single column definition, thats repeated, so you'd basically just move the logic in your dsh CreateCell method, to the column's CreateCell method.
Does that make sense?
-SteveZ
Steve,
Sorry, but after looking into SingleRowDatasourcehelper i am still not clear how it is going to help me.
I have 16 rows, each row has unique cells and dynamic number of columns. Today my IGGridViewDataSourceHelper returns numberofColumns, numberofFixedColumns etc.....
From rowid I know which cell to create but now I want to use editable cells feature (available in ColumnDefinitions) and am not sure how to achieve similar functionality since I do not have named column names - each row contains the same column.
any suggestion
thank you
mark
So i realized one other thing. When you dismiss the keyboard, we're listening to the delegate on the text editor, calling endEditing() on the DatasourceHelper. But again, that isn't resolving your column properly, b/c we're bypassing the normal column definitions.
However, what we should be doing, is overriding EndEditing, and handling things there ourselves:
public override void DidEndDisplayingCell(IGGridView gridView, IGGridViewCell cell, IGCellPath path) { if (cell == _editCell) { this.EndEditing (); } } public override void EndEditing () { if (_editCell != null) { IGCellPath normPath = this.NormalizePath(_editCell.Path); var colDef = this.ColumnDefinitions.GetItem<NSObject>(normPath.RowIndex) as IGGridViewColumnDefinition; colDef.RemoveEditor(_editCell.GridView, _editCell.Path, this, false, false); _editCell = null; } }
I noticed that when you i collapsed the keyboard, and clicked on another cell, the last edit mode cell was still in edit mode, and it would transition. This should hopefully fix that. Can you try it out and let me know?
Thanks!
no, did not help - problem is still there.
look at the attached video once more.
All I do is edit mode, dismiss keyboard, fast scroll (in a multiple cycles) and then it gets stuck. I need at least 5 clicks to get it into edit mode.
As mentioned I had similar problem in my code handling edit on my own w/o use of column definition editor, seems with editor problem is the same.
on a video you can see with in a minute I got stuck twice.
I've watched the video a lot. I still have not been able to reproduce it though, and i'm using the sample you gave me... So i'm kind of operating blindly, so i really appreciate your patience.
When you're clicking on a cell, and its not doing anything, is the Tapped event not firing at all? Maybe stick in a Console.WriteLine("Tapped") to see if thats the case. If its not firing, it means that gesture didn't get registered, or something else is capturing it, and that would be really puzzling..
One other thing i just noticed which we should fix, is to no use the RegisterGestures method. RegisterGestures will keep registering the same event over and over again. Which could potentially be causing issues, and may be the problem. Basically that method is meant to be called once, like in initialize cell, and not overtime the cell is reused. For cases where we are attaching the gesture every time a cell is being reused, we should be using RegisterTemporaryGestures:
if (this.AllowEditing && colDef.Editable) { var tapGesture = new UITapGestureRecognizer(this, new MonoTouch.ObjCRuntime.Selector("HandleEdit:")) { NumberOfTapsRequired = 1 }; cell.RegisterTemporaryGestures(new NSObject[] { tapGesture }); }
Now, i have no idea if thats the cause, ( i actually doubt it is), but its definitely worth fixing, as it could lead to issues down the road.
steve,
thank you for your response.
I do not get any tap events when i get stuck. I need to click in a different areas of the cell to get it going again.
Anyway, let me see if I can create for you more consistent scenario to demonstrate the problem I am having.
ok, i finally reproduced missing clicks on a cell and they are to do with IGSlideTabView.
Please run attached example and watch recorder screen. I really hope u can reproduce this problem (not just watching the video). this is my original problem and the reason I decided to adapt to ColumnDefinitions use for editing but seems the problem exists regardless.
1. in portrait mode - click cell next to a tab (say 5.6)2. rotate into landscape mode3. click again in on cells around cell 5.4 - PROBLEM!!!! behaving very erratic.
Got the fix - all good.
Thank you again
Yes, as soon as we get it fixed, we will send you a private build.
Thanks again for your patience, and creating that sample.
Hope you have a good weekend as well!
that is a great news. many days trying to resolve thinking it is to do with cells and editors until last night when I decided to add sliderview.
thank you very much
hopefully once it is fixed I will be able to get a private build again
have a great weekend
Ok i figured it out.
Looks like there is a bug in the tab view, where floating hit targets for the tabs aren't getting positioned correctly when you rotate.
My developer that works on the tab view is out today, but i'll have him look into it first thing next week.
I was able to figure out what was happening by looping through all the the views in the hierarchy and apply a border so that i could see if anything rogue was floating around.
this.applyBorderToAllSubViews (this.View); private void applyBorderToAllSubViews(UIView view) { foreach (UIView v in view.Subviews) { this.applyBorderToAllSubViews (v); v.Layer.BorderColor = UIColor.Red.CGColor; v.Layer.BorderWidth = 1; } }
Thanks for the sample. I was finally able to reproduce it!!
Unfortunately, right now i have no idea whats the issue... Its really weird. There is basically a dead spot that occurs, and you can't even scroll on that area. Something is eating the event, but if you click slightly to the left, or slightly to the right of it, it works fine...
I wish Xamarin had a visual inspector that I could use to debug like Xcode does, then i could see if there is some rogue invisible element floating there. (Although i kind of doubt it, since it eventually goes away...)
Anyways, this may take some time to debug, but i just wanted to let you know that i am looking into it.