We are Using the Sfdatagrid added using Nuget in our project.While adding a Column as Numeric Column we are facing an exception "Specified Cast Not Valid" after editing the column and moving to next column.The exception is not thrown when using the column as Text Column but we need the Keyboard while editing the column to be numeric keypad which as per your documentation can only be achieved if the column is GridNumeric Column.
Please find the implemenation detailed description
we added the gridcontrol to the Layout,
then added the columns as below :
GridTextColumn jo = new GridTextColumn();
jo.MappingName = "JobOrder";
jo.HeaderText = "JobOrder No";
jo.HeaderCellTextSize = 20;
jo.CellTextSize = 16;
jo.IsHidden = false;
jo.Width = 170;
jo.AllowEditing = true;
GridTextColumn op = new GridTextColumn();
op.MappingName = "OprCode";
op.HeaderText = "OprCode";
op.IsHidden = false;
op.Width = 120;
op.HeaderCellTextSize = 20;
op.CellTextSize = 16;
op.AllowEditing = false;
GridTextColumn jq = new GridTextColumn();
jq.MappingName = "JobQty";
jq.HeaderText = "JobQty";
jq.IsHidden = false;
jq.Width = 120;
jq.HeaderCellTextSize = 20;
jq.CellTextSize = 16;
jq.AllowEditing = false;
GridTextColumn rc = new GridTextColumn();
rc.MappingName = "RC";
rc.HeaderText = "RC No";
rc.IsHidden = false;
rc.Width = 160;
rc.HeaderCellTextSize = 20;
rc.CellTextSize = 16;
rc.AllowEditing = false;
GridNumericColumn pq = new GridNumericColumn();
pq.MappingName = "PQ";
pq.HeaderText = "PQ No's";
pq.IsHidden = false;
pq.Width = 120;
pq.HeaderCellTextSize = 20;
pq.CellTextSize = 16;
pq.AllowEditing = true;
GridTextColumn sc = new GridTextColumn();
sc.MappingName = "Scrap";
sc.HeaderText = "Scrap No's";
sc.IsHidden = false;
sc.Width = 120;
sc.HeaderCellTextSize = 20;
sc.CellTextSize = 16;
GridTextColumn rj = new GridTextColumn();
rj.MappingName = "Reject";
rj.HeaderText = "Reject No's";
rj.IsHidden = false;
rj.Width = 120;
rj.HeaderCellTextSize = 20;
rj.CellTextSize = 16;
GridTextColumn sk = new GridTextColumn();
sk.MappingName = "Skip";
sk.HeaderText = "To Skip";
sk.IsHidden = false;
sk.Width = 160;
sk.HeaderCellTextSize = 20;
sk.CellTextSize = 16;
sk.AllowEditing = false;
GridImageColumn sv = new GridImageColumn();
sv.MappingName = "save";
sv.HeaderText = "Save";
sv.IsHidden = false;
sv.Width = 150;
sv.HeaderCellTextSize = 20;
sv.CellTextSize = 20;
GridTextColumn ed = new GridTextColumn();
ed.MappingName = "iseditable";
ed.HeaderText = "iseditable";
ed.IsHidden = true;
ed.Width = 120;
ed.HeaderCellTextSize = 14;
ed.CellTextSize = 20;
ed.AllowEditing = false;
GridTextColumn sq = new GridTextColumn();
sq.MappingName = "OpeSeq";
sq.HeaderText = "oprseq";
sq.IsHidden = true;
sq.Width = 120;
sq.HeaderCellTextSize = 14;
sq.CellTextSize = 20;
sq.AllowEditing = false;
GridTextColumn aw = new GridTextColumn();
aw.MappingName = "AwaitingQty";
aw.HeaderText = "AwtQty";
aw.IsHidden = true;
aw.Width = 120;
aw.HeaderCellTextSize = 14;
aw.CellTextSize = 20;
aw.AllowEditing = false;
sfgrid.Columns.Add(jo);
sfgrid.Columns.Add(op);
sfgrid.Columns.Add(jq);
sfgrid.Columns.Add(rc);
sfgrid.Columns.Add(pq);
sfgrid.Columns.Add(sc);
sfgrid.Columns.Add(rj);
sfgrid.Columns.Add(sk);
sfgrid.Columns.Add(sv);
sfgrid.Columns.Add(ed);
sfgrid.Columns.Add(sq);
sfgrid.Columns.Add(aw);
sfgrid.AutoGeneratingColumn += GridAutoGeneratingColumns;
Please find the GridAutoGeneratingColumns below
public void GridAutoGeneratingColumns(object sender, AutoGeneratingColumnEventArgs e)
{
//if (e.Column.MappingName == "ItemCode")
// e.Column.IsHidden = true;
//if (e.Column.MappingName == "ItemName")
// e.Column.Width = 210;
//if (e.Column.MappingName != "ItemName")
// e.Column.Width = 70;
//if (e.Column.MappingName != "Disc%")
e.Column.AllowEditing = true;
e.Column.TextAlignment = GravityFlags.Center;
e.Column.HeaderCellTextSize = 20;
e.Column.HeaderFont= Typeface.Create(Typeface.CreateFromAsset(Application.Context.Assets, "Roboto-Regular.ttf"), TypefaceStyle.Bold);
}
then datasource is specified as list of Model as shown below
Mitems = new List<ModProduction>();
try
{
Mitems = LoadProd();
if (Mitems.Count == 0 || Mitems == null)
{
ShowInfoAlert("Unable to fetch Job list!! App will malfunction !!");
return;
}
}
catch (Exception ex)
{
ShowInfoAlert(ex.ToString());
ShowInfoAlert("Network connection Failed!!");
return;
}
sfgrid.ItemsSource = Mitems;
sfgrid.AllowEditing = true;
sfgrid.SelectionMode = SelectionMode.Single;
sfgrid.NavigationMode = NavigationMode.Cell;
sfgrid.RowHeight = 70;
sfgrid.ScrollingMode = ScrollingMode.PixelLine;
sfgrid.HorizontalScrollBarEnabled = true;
//grid.Columns[4].AllowEditing = true;
sfgrid.Columns[0].AllowEditing = true;
sfgrid.EditTapAction = TapAction.OnTap;
sfgrid.AutoGenerateColumns = true;
Please find us a solution so that we can use your products more efficiently.