I have a dataset that contains 0 or 1 for a column. I want to be able to display this with a check box - is this possible in 2016.1 release of Nuclios ?
Hi,
In iOS there aren't any Checkbox controls. The closest the native toolset has is the UISwitch.
As for customizing the IGGridView, it's built to be completely customizable, So you can create custom columns and cells to display whatever you'd like.
So, if you wanted to display a UISwitch, that would be trivial.
I could put together a sample to show you how to do this. Just let me know what Language you're using. (Obj-c, Swift, or Xamarin C#)
-SteveZ
Thank you for responding rapidly Stephen.
UISwitch is what I was trying to say !
I am building a tablet app with Xamarin.iOS using C#. Right now the column definition is a standard one displaying 0 or 1.
Looking forward to your sample - the custom column definition code would be more than enough.
Thank you in advance.
Ok, great :)
I've attached a sample that shows an example of a "checkbox" column.
_dsh.ColumnDefinitions.Add(new CheckboxColumn("boolProp"));
Then Create a column, that is in charge of passing around your custom cell:
public class CheckboxColumn : IGGridViewColumnDefinition { public CheckboxColumn(String key) : base(key) { } public override IGGridViewCell CreateCell(IGGridView gridView, IGCellPath path, IGGridViewDataSourceHelper dataSource) { CheckboxCell cell = (CheckboxCell)gridView.DequeueReusableCell("cb"); if (cell == null) { cell = new CheckboxCell("cb"); } bool val = ((NSNumber)dataSource.ResolveDataValueForCell(path)).BoolValue; cell.UpdateValue(val); return cell; } }
Then create your custom cell :
public class CheckboxCell : IGGridViewCell { UISwitch _switch; public CheckboxCell(String identifier) : base(identifier) { _switch = new UISwitch(); this.AddSubview(_switch); } public override void SetupSize(CoreGraphics.CGSize size) { base.SetupSize(size); _switch.Frame = new CoreGraphics.CGRect(0, 0, size.Width, size.Height); } public void UpdateValue(bool val) { _switch.On = val; } }
Hope this helps!
Dear Stephen,
Is it possible to post a swift example?
Works like a charm. Thanks.