示例#1
0
        private void dgvData_EditorRequired(object sender, EditorRequiredEventArgs e)
        {
            GridViewEditManager manager = sender as GridViewEditManager;

            // Assigning DropDownListAddEditor to the right column
            if (manager.GridViewElement.CurrentColumn.Name == "Department")
            {
                DropDownListAddEditor editor = new DropDownListAddEditor();
                editor.InputValueNotFound += new DropDownListAddEditor.InputValueNotFoundHandler(DropDownListAddEditor_InputValueNotFound);
                e.Editor = editor;
            }
        }
        private void newGrid_CellEndEdit(object sender, GridViewCellEventArgs e)
        {
            var    originalType = e.Column.GetType();
            object newValue     = e.Value;

            GridViewEditManager manager = (GridViewEditManager)sender;
            RadGridView         grid    = manager.GridViewElement.GridControl;

            if (e.Column.HeaderText == "Max Workers Per VM" && newValue != null)             // Special case for Office Workers, set value to default
            {
                int maxAllowedResources = _context.ResourceTypes.First(n => n.Name == "OfficeWorker").MaxResourcesPerHost;

                int num = (int)newValue;
                if (num > maxAllowedResources || num < 1)
                {
                    newValue = maxAllowedResources;
                }
            }
            else if (originalType == typeof(GridViewDecimalColumn) && (newValue == null || (int)newValue < 1))             // Prevents the user from inputting a negative value
            {
                newValue = 1;
            }

            foreach (var info in grid.SelectedCells)
            {
                if (info.ColumnInfo.Name == e.Column.Name)
                {
                    info.Value = newValue;
                }

                if (info.RowInfo.GetType() != typeof(GridViewFilteringRowInfo))                 // Do not allow filtering cells to be filled in
                {
                    if (info.ColumnInfo.Name == e.Column.Name)
                    {
                        info.Value = newValue;
                    }
                }
            }
        }