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
I'd be happy to help.
However, I don't think i'm following 100%. So can you help explain what you're trying to achieve? Also if you have a screen shot, that'd be great.
When you say you have 16 rows. Do you mean you have 16 rows in the grid? or 16 items in the array of data you're binding?
You also say that each row has dynamic number of columns. I'm a bit lost here, b/c the IGGridView only supports a single value for number of columns across all rows.
Does this mean you're using nested grids? So each row has its own horizontally scrolling grid?
Attached is an example demonstrating my problem - I cannot get cell into edit mode unless I assigned to DataSource.Data some data. This worked fine using standard DataSourceHelper because I manipulated my own EditView control but with column definitions seems that I must have data assigned.
The process is like this
1. I paint a grid based on delegates columns and rows
2. each cell is mapped to some internal matrix cell
3. CreateCell creates correct ViewCell with data that is located in that matrix
Thanks
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!
Thank you - that helps.
Since DisplayEditor is invoked now manually how do I handle RemoveEditor override?
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.