protected void Page_Load(object sender, EventArgs e)
{
List<Model.Goods> list = GetData();
FpSpread1.ActiveSheetView.DataSource = list;
}
protected void FpSpread1_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
{
if (e.CommandName == "AddClickCommand")
{
FpSpread1.SaveChanges();
List<Model.Goods> list = FpSpread1.ActiveSheetView.DataSource as List<Model.Goods>;
int i = this.FpSpread1.ActiveSheetView.SelectionModel.AnchorRow;
bool b = this.FpSpread1.ActiveSheetView.SelectionModel.IsAnyCellInRowSelected(i);
if (!b)
{
return;
}
Model.Goods g = list;
g.Status = 1;
int chindrencount = GetChildrenCount(list, g.ID);
int maxid = list.Max(n => n.ID);
int rowindex = list.IndexOf(g);
list.Insert(rowindex + 1, new Model.Goods() { ID = maxid + 1, ParentID = g.ID, Level = g.Level + 1, Status = 1, Sort = chindrencount + 1, Name = "", Remark = "", Count = 0, Price = 0, Total = 0, Type = 2 });
//
TreeCellType tree = new TreeCellType();
tree.list = list;
FpSpread1.ActiveSheetView.Columns[0].CellType = tree;
FpSpread1.ActiveSheetView.DataSource = list;
}
}
运行FpSpread1_ButtonCommand事件后list更加一行了,但是显示时最后一行不显示。 |
|