Grid Lookup Column and Popup

6 posts, 0 answers
  1. Daniel
    Daniel avatar
    22 posts
    Member since:
    Jan 2008

    Posted 14 Jan 2016 Link to this post

    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. 

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3714 posts

    Posted 18 Jan 2016 Link to this post

    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
  3. Daniel
    Daniel avatar
    22 posts
    Member since:
    Jan 2008

    Posted 19 Jan 2016 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    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. 

  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3714 posts

    Posted 20 Jan 2016 Link to this post

    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
  5. reyhane
    reyhane avatar
    7 posts
    Member since:
    Oct 2019

    Posted 16 Dec 2019 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    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

  6. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3714 posts

    Posted 17 Dec 2019 Link to this post

    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.
Back to Top