This is a migrated thread and some comments may be shown as answers.

RadDropDownListEditorElement Items visible

1 Answer 31 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Вадим
Top achievements
Rank 1
Iron
Вадим asked on 26 Jun 2018, 03:27 PM
private void radGridView5_CellEditorInitialized(object sender, GridViewCellEventArgs e)
        {
            if (e.Column.Name == "operati")
            {
                RadDropDownListEditor editors = (RadDropDownListEditor)e.ActiveEditor;
                RadDropDownListEditorElement elements = (RadDropDownListEditorElement)editors.EditorElement;
 
                switch (_endOperationSoc)
                {
                    case "принят":
                        elements.Items.RemoveAt(4);
                        elements.Items.RemoveAt(1);
                        break;
                    case "приостановлен":
                        elements.Items.RemoveAt(3);
                        elements.Items.RemoveAt(1);
                        break;
                    case "снят":
                        elements.Items.RemoveAt(4);
                        elements.Items.RemoveAt(3);
                        elements.Items.RemoveAt(2);
                        break;
                    case "возобновлен":
                        elements.Items.RemoveAt(4);
                        elements.Items.RemoveAt(1);
                        break;
                }
            }
 
            if (e.Column.HeaderText == "соц. работник")
            {
                RadDropDownListEditor editors = (RadDropDownListEditor)e.ActiveEditor;
                RadDropDownListEditorElement elements = (RadDropDownListEditorElement)editors.EditorElement;
                if (radGridView5.RowCount != 0)
                    elements.SelectedIndex = elements.FindString(radGridView5.Rows[radGridView5.RowCount - 1].Cells[1].Value.ToString());
            }
 
            RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor;
 
            if (editor == null)
            {
                return;
            }
 
            RadDropDownListElement element = editor.EditorElement as RadDropDownListEditorElement;
 
            int scrolBarWidth = 0;
 
            if (element.DefaultItemsCountInDropDown < element.Items.Count)
            {
                scrolBarWidth = 35;
            }
 
            foreach (RadListDataItem item in element.Items)
            {
                string text = item.Text;
                Size size = TextRenderer.MeasureText(text, element.Font);
 
                if (element.DropDownWidth < size.Width)
                {
                    element.DropDownWidth = size.Width + scrolBarWidth;
                }
            }
        }

here is this moment:

switch (_endOperationSoc)
                {
                    case "принят":
                        //elements.Items[4].IsVisible = false;
                        elements.Items.RemoveAt(4);
                        elements.Items.RemoveAt(1);
                        RadMessageBox.Show("принят", "Ошибка", MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                        break;
                    case "приостановлен":
                        elements.Items.RemoveAt(3);
                        elements.Items.RemoveAt(1);
                        RadMessageBox.Show("приостановлен", "Ошибка", MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                        break;
                    case "снят":
                        elements.Items.RemoveAt(4);
                        elements.Items.RemoveAt(3);
                        elements.Items.RemoveAt(2);
                        RadMessageBox.Show("снят", "Ошибка", MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                        break;
                    case "возобновлен":
                        elements.Items.RemoveAt(4);
                        elements.Items.RemoveAt(1);
                        RadMessageBox.Show("возобновлен", "Ошибка", MessageBoxButtons.OK, RadMessageIcon.Exclamation);
                        break;
                }
            }

How do I not delete items but just hide or display them?
It is necessary to do it in this moment.
Thank you.

 

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 27 Jun 2018, 06:42 AM
Hello Vadim,

The only other way is to set the Height of the items:
RadDropDownListEditor editor = (RadDropDownListEditor)e.ActiveEditor;
if (editor != null)
{
    RadDropDownListEditorElement element = (RadDropDownListEditorElement)editor.EditorElement;
    element.Items[0].Height = 0;
}

I hope this will be useful. 

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Вадим
Top achievements
Rank 1
Iron
Answers by
Dimitar
Telerik team
Share this question
or