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

Grid Lookup Column and Popup

5 Answers 252 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 14 Jan 2016, 03:40 PM

I've attached a picture from an application that I'm trying to mimic, and I"m unsure how to do this with the GridView.

 

1) The ellipses lookup button on a column. Basically the same display functionality as the GridViewBrowseColumn, but rather than opening an OPenFileDialog, I want to open another WinForm that I'd pass data back and forth between.

 2) The alert icon in the column - alerting the user that there is some information to be displayed. 

 

Can anyone help by pointing me in the direction of a sample that has functionality like this, or offering some ideas on how best to accomplish? Currently, I have a command column that is performing the Lookup Function, but as the user moves columns around, it may not be in the correct place, so I don't think that's the correct path. 

5 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 18 Jan 2016, 12:19 PM
Hello Daniel,

Thank you for writing.

You can use a custom GridBrowseEditor editor and display a custom form. Here is a sample code snippet:
public Form1()
{
    InitializeComponent();
 
    this.radGridView1.EditorRequired += radGridView1_EditorRequired;
}
 
private void radGridView1_EditorRequired(object sender, Telerik.WinControls.UI.EditorRequiredEventArgs e)
{
    if (this.radGridView1.CurrentColumn.Name == "CategoryName")
    {
        e.Editor = new MyBrowseEditor(this.radGridView1.CurrentColumn.Name);
    }
}
 
public class MyBrowseEditor : GridBrowseEditor
{
    private string editorColumnName;
 
    public MyBrowseEditor(string columnName) : base()
    {
        this.editorColumnName = columnName;
    }
 
    protected override RadElement CreateEditorElement()
    {
        return new MyRadBrowseEditorElement(editorColumnName);
    }
}
 
public class MyRadBrowseEditorElement : GridBrowseEditorElement
{
    private string editorElementColumnName;
 
    public MyRadBrowseEditorElement(string editorColumnName) : base()
    {
        this.editorElementColumnName = editorColumnName;
    }
 
    protected override void OnBrowseButtonClick(EventArgs e)
    {
        EditorForm editorForm = new EditorForm(this.Value);
        DialogResult result = editorForm.ShowDialog();
        if (result == DialogResult.OK)
        {
            this.Value = editorForm.TextBox.Text;
        }
    }
}

As to the alert icon, you can use a similar approach and insert the desired element in the custom editor's children.

I hope this information helps. Should you have further questions I would be glad to help.
 
Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Daniel
Top achievements
Rank 1
answered on 19 Jan 2016, 10:43 PM

Thank you - that is most helpful.

 As a follow-up, how can I allow the user to type in that field, as well as use the lookup button? The use of the editor is not required in my application. 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 20 Jan 2016, 02:19 PM
Hello Daniel,

Thank you for writing back. 
 
In order to allow the user to type inside the GridBrowseEditor, you can set the GridBrowseEditorElement.ReadOnly property to false:
 
public class MyRadBrowseEditorElement : GridBrowseEditorElement
{
    private string editorElementColumnName;
 
    public MyRadBrowseEditorElement(string editorColumnName) : base()
    {
        this.editorElementColumnName = editorColumnName;
        this.ReadOnly = false;
    }
}

I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
reyhane
Top achievements
Rank 1
answered on 16 Dec 2019, 09:39 AM

Hello 

I have below code:

private void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
       {
           GridViewEditManager editManager = sender as GridViewEditManager;
           bool isGridBrowseEditor = e.EditorType == typeof(GridBrowseEditor);
           if (isGridBrowseEditor)
           {
               GridBrowseEditor editor = new GridBrowseEditor();
               RadBrowseEditorElement el = editor.EditorElement as RadBrowseEditorElement;
 
               if (el != null)
               {
                   if (!tbSubscribed)
                   {
                       tbSubscribed = true;
                       // RadTextBoxEditorElement tbElement = (RadTextBoxEditorElement)e.Editor;//tbEditor.EditorElement;
                       el.KeyDown -= new KeyEventHandler(tbElement_KeyDown);
                       el.KeyDown += new KeyEventHandler(tbElement_KeyDown);
 
                       el.TextBoxItem.GotFocus -= new EventHandler(TextBoxItem_GotFocus);
                       el.TextBoxItem.GotFocus += new EventHandler(TextBoxItem_GotFocus);
 
 
                   }
               }
 
                
                
             
               e.Editor = new MyBrowseEditor(editManager.GridViewElement.CurrentColumn.Name);
 
               
 
           }
       }

 

but doesn't call my KeyDown event by typing in GridViewBrowseColumn !!

have you any solution?

Thanks in advance for your help

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 Dec 2019, 07:01 AM

Hello, Reyhane,     

Your question has already been answered in the other thread you have opened on the same topic. Please, see our answer there for more information.
We kindly ask you to use just one thread for a specific problem to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two or more tickets instead of one. Moreover, threads are handled according to license and time of posting, so if it is an urgent problem, we suggest you use a support ticket, which would be handled before a forum thread.

Thank you for your understanding.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Daniel
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Daniel
Top achievements
Rank 1
reyhane
Top achievements
Rank 1
Share this question
or