private void gridControl1_ViewRegistered(object sender, DevExpress.XtraGrid.ViewOperationEventArgs e) { GridView detailView = e.View as GridView; detailView.OptionsSelection.MultiSelect = true; detailView.OptionsSelection.MultiSelectMode = GridMultiSelectMode.CheckBoxRowSelect; if (detailView != null) { detailView.CustomRowCellEdit -= detailView_CustomRowCellEdit; detailView.CustomRowCellEdit += detailView_CustomRowCellEdit; detailView.RowCellStyle -= detailView1_RowCellStyle; detailView.RowCellStyle += detailView1_RowCellStyle; detailView.ShownEditor -= detailView_ShownEditor; detailView.ShownEditor += detailView_ShownEditor; detailView.SelectionChanged -= detailView_SelectionChanged; detailView.SelectionChanged += detailView_SelectionChanged; detailView.RowUpdated -= detailView_RowUpdated; detailView.RowUpdated += detailView_RowUpdated; detailView.MouseDown -= gridView1_MouseDown; detailView.MouseDown += gridView1_MouseDown; detailView.ValidateRow -= detailView_ValidateRow; detailView.ValidateRow += detailView_ValidateRow; detailView.InvalidRowException -= detailView_InvalidRowException; detailView.InvalidRowException += detailView_InvalidRowException; detailView.RowDeleting -= detailView1_RowDeleting; detailView.RowDeleting += detailView1_RowDeleting; detailView.RowDeleted -= detailView1_RowDeleted; detailView.RowDeleted += detailView1_RowDeleted; } //初始化供应商dropdownlist //_positionRepItem.Name = "DropDownForPosition"; //_positionRepItem.DataSource = _managementService.GetPositionNameByCode(null); //gridControl1.RepositoryItems.Add(_positionRepItem); //GridColumn aColumn = detailView.Columns[nameof(model.Position)]; //aColumn.ColumnEdit = _positionRepItem; var colReApplication = new GridColumn() { Name = "Action", Visible = true, VisibleIndex = 26, ColumnEdit = this.repositoryItemButtonEdit1 }; detailView.Columns.Add(colReApplication); detailView.Columns[nameof(childModel.PurchaseId)].Visible = false; detailView.Columns[nameof(childModel.SupplierCode)].Visible = false; detailView.Columns[nameof(childModel.PurchaseNumber)].Visible = false; detailView.Columns[nameof(childModel.ItemId)].Visible = false; detailView.Columns[nameof(childModel.IsPriceChange)].Visible = false; detailView.Columns[nameof(childModel.PoNumber)].Visible = false; detailView.Columns[nameof(childModel.IsDeleted)].Visible = false; detailView.Columns[nameof(childModel.RequestId)].Visible = false; detailView.Columns[nameof(childModel.Position)].Visible = false; RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.SupplierCode)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.ApplicationNumber)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.Name)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.Category)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.Code)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.Brand)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.Model)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.Specification)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.Dimension)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.Unit)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.DefaultPrice)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.PurchaseTotal)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.TotalPrice)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.AlreadyInStock)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.Status)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.Position)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.LastDeliveryDate)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.UpdateDate)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.PoNumber)]); RenderCommonHelper.SetColNotEditable(detailView.Columns[nameof(childModel.IsDeleted)]); detailView.Columns[nameof(childModel.DefaultPrice)].DisplayFormat.FormatType = FormatType.Numeric; detailView.Columns[nameof(childModel.DefaultPrice)].DisplayFormat.FormatString = "c2"; detailView.Columns[nameof(childModel.Price)].DisplayFormat.FormatType = FormatType.Numeric; detailView.Columns[nameof(childModel.Price)].DisplayFormat.FormatString = "c2"; detailView.Columns[nameof(childModel.TotalPrice)].DisplayFormat.FormatType = FormatType.Numeric; detailView.Columns[nameof(childModel.TotalPrice)].DisplayFormat.FormatString = "c2"; detailView.Columns.ForEach(x => x.OptionsFilter.AllowFilter = false); }
protected override void detailView1_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e) { GridView currentView = sender as GridView; if (e.Column.FieldName == nameof(childModel.SelectedPurchaseNumber)) { Enum.TryParse(currentView.GetRowCellValue(e.RowHandle, nameof(parentModel.AuditStatus)).ToString(), out AuditStatusEnum auditStatus); if (auditStatus == AuditStatusEnum.未审批) { PurchaseApplicationViewModel model = (PurchaseApplicationViewModel)currentView.GetRow(e.RowHandle); RepositoryItemLookUpEdit purchaseRepItem = new RepositoryItemLookUpEdit(); purchaseRepItem.Name = "DropDownForPurchaseNumber"; purchaseRepItem.NullText = ""; purchaseRepItem.ValueMember = nameof(PurchaseModel.PurchaseNumber); purchaseRepItem.DisplayMember = nameof(PurchaseModel.PurchaseNumber); purchaseRepItem.DataSource = listOfPurchaseViewModels.Where(x => x.Code == model.Code); purchaseRepItem.PopulateColumns(); purchaseRepItem.PopupWidth = 500; //purchaseRepItem.Columns[nameof(PurchaseModel.PurchaseId)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.RequestId)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.ApplicationNumber)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.PoNumber)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.Category)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.Name)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.Code)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.Brand)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.Model)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.Specification)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.Dimension)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.Unit)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.DefaultPrice)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.Price)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.TotalPrice)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.ReadyForInStock)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.Status)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.IsDeleted)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.AlreadyInStock)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.Position)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.Note)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.DeliveryDate)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.UpdateDate)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.IsPriceChange)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.ItemId)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.LastDeliveryDate)].Visible = false; //purchaseRepItem.Columns[nameof(PurchaseModel.CorrectionTotal)].Visible = false; //gridControl1.RepositoryItems.Add(positionRepItem); e.RepositoryItem = purchaseRepItem; purchaseRepItem.EditValueChanged -= RepositoryItemLookUpEdit1_EditValueChanged; purchaseRepItem.EditValueChanged += RepositoryItemLookUpEdit1_EditValueChanged; RenderCommonHelper.SetColEditable(e.Column); } else if (auditStatus == AuditStatusEnum.已审批) { RenderCommonHelper.SetColNotEditable(e.Column); } } if (e.Column.FieldName == nameof(parentModel.TotalConfirmed)) { Enum.TryParse(currentView.GetRowCellValue(e.RowHandle, nameof(parentModel.AuditStatus)).ToString(), out AuditStatusEnum auditStatus); if (auditStatus == AuditStatusEnum.已审批) { RenderCommonHelper.SetColNotEditable(e.Column); } if (auditStatus == AuditStatusEnum.未审批) { RenderCommonHelper.SetColEditable(e.Column); } } if (e.Column.FieldName == nameof(parentModel.AuditStatus)) { Enum.TryParse(currentView.GetRowCellValue(e.RowHandle, nameof(childModel.ProcessStatus)).ToString(), out ProcessStatusEnum processStatus); if (processStatus == ProcessStatusEnum.申请审核中) { RenderCommonHelper.SetColEditable(e.Column); } if (processStatus != ProcessStatusEnum.申请审核中) { RenderCommonHelper.SetColNotEditable(e.Column); } } }