Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
470
Reserve some deleting rows failure
posted

In the fuction, the event argument e is changed, but the rows i want to reserve are still deleted by the ultragrid.


        protected override void OnBeforeRowsDeleted(BeforeRowsDeletedEventArgs e)
        {
            if (MsgHelper.Confirm("是否确定删除选中的行?"))
            {
                List<UltraGridRow> listRow = new List<UltraGridRow>();
                for (int i = e.Rows.Length - 1; i >= 0; i--)
                {
                    if (e.Rows[i].IsAddRow) continue;
                    Details detail = e.Rows[i].ListObject as Details;
                    if (detail.Id != 0)                                         // Some details.Id aren't equal to 0
                    {
                        e.Rows[i].Hidden = true;
                        detail.Deleted = true;
                    }
                    else
                        listRow.Add(e.Rows[i]);
                }
                e = new BeforeRowsDeletedEventArgs(listRow.ToArray(), false);
                MsgHelper.Info("数据已删除成功.");
            }
            else
            {
                MsgHelper.Info("操作已取消.");
                e.Cancel = true;
            }

            base.OnBeforeRowsDeleted(e);
        }

  • 469350
    Offline posted

    Setting e to a new instance will not work. I think what you have to either modify e.Rows, or if that doesn't work, you would have to set e.Cancel to true and delete the rows you want while leaving the others alone.