Hi - I'm curious to know if you have a recommendation for handling an insert of a row in your gridView. I know how to perform an insert, but I'm looking if their is a recommendation on the design. Xamarin recommends using the:
(Image below of the standard UITableView in EditMode)
EditingStyleForRow – returns UITableViewCellEditingStyle.Delete for the rows containing data, and returns UITableViewCellEditingStyle.Insert for the last row (which will be added specifically to behave as an insert button).
Do you guys have anything like this where the last row in the gridVIew will be a button to "Add New" or should I just use a button somewhere?
http://docs.xamarin.com/guides/ios/user_interface/tables/part_4_-_editing
Ok, figured it out.
I had switched to using the beta builds of Xamarin.iOS to take advantage of another feature. Apparently it works there, but once i switched back to their stable builds it breaks. (Must be a bug with them)
However, you can still use the feature, just switch from using an IGRowPath to an IGCellPath:
DummyData obj = (DummyData)_dsh.ResolveDataObjectForRow (new IGCellPath(0,0,0));
Just make the columnIndex you pass in 0.
Thats it.
Sorry about that,
-SteveZ
Odd - I've attached a screen shot of the error. I'm using NuciOS 13.1. Not sure if this helps any, I'm running Xamarin Studio 4.0.7 (build 3) as well.
Hmm, i'm not exactly sure what issue you're running into.
Using the sample i attached, i simply added the following line to the end of ViewDidLoad, like you suggested:
DummyData obj = (DummyData)_dsh.ResolveDataObjectForRow (new IGRowPath(0,0));
However, it's always returning an object for me.
Hey Steve - So this is really close to what I'm looking for, however, using the new IGGridViewDataSourceHelper, I can no longer use the _dsh.ResolveDataObjectForRow. It says cannot convert IGRowPath to IGCellPath. I'm using this method to access data that is in the object but not displayed on the _gridView. Like if the Patient ID was to be referenced but not displayed in the grid itself.
I was thinking I would need to use ResolveDataValueForCell but it doesn't work if that column is not displayed in the _GridView. Not sure what the proper approach is for this. Let me know if you need a sample app. It's just adding:
NSObject obj = _dsh.ResolveDataObjectForRow(row) at the end of the ViewDidLoad
Thanks for you help on this.
Sure thats no problem.
I've attached a sample that shows how to do this. (It's in C#)
B/c of the way bindings work, any method that you override from our DataSourceHelper that comes from the DataSource protocol, can not have it's base implementation raised. So i've filled out all the code from what would have been the base class.
Some things to note:
1. You simply would replace the IGGridViewDataSourceHelper that you're using with this one.
2. I've implemented it so that the "add new" row is added to the top. You can easily modify the code though and place it at the bottom
3. I've stuck a button in the cell for the add new functionality. However, you could just set the cell's text, or provide a custom cell, and listen to the cell selection delegate events.
4. You'll notice i overrode 3 methods. NumberOfRowsInSection, CreateCell and finally GetStretchRows. The latter is simply asking for any rows that should ignore the columns and just appear as one long cell.
I hope this helps.
Feel free to let me know if you have any questions or if anything isn't clear.