cellclick from template grid

6 posts, 1 answers
  1. Andre
    Andre avatar
    41 posts
    Member since:
    Feb 2018

    Posted 18 Mar 2018 Link to this post

    how can I detect if the cellclick comes from the template or the master grid?

     

    thanks

    andre

  2. Dimitar
    Admin
    Dimitar avatar
    2684 posts

    Posted 19 Mar 2018 Link to this post

    Hi Andre,

    Thank you for writing. 

    You can use the following approach for this:
    private void RadGridView1_CellClick(object sender, GridViewCellEventArgs e)
    {
        if (e.Row.ViewTemplate == radGridView1.MasterTemplate)
        {
            Console.WriteLine("Master");
        }
        else
        {
            Console.WriteLine("Child");
        }
    }

    I hope this will be useful. Let me know if you have additional questions.

    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.
  3. Andre
    Andre avatar
    41 posts
    Member since:
    Feb 2018

    Posted 20 Mar 2018 in reply to Dimitar Link to this post

    thanks for the solution. 
    i said something wrong. i want to call a contextMenu only from a templategrid. i couldn't find a cellclick event for a templategrid.
    so far I have done the following without success.

           private void dgvOrder_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
            {
                if (e.ContextMenuProvider is GridCellElement cellElement) {
                    if (cellElement is GridDetailViewCellElement detailCell) {
                        e.ContextMenu = _contextMenuOperation;
                    }

                    Console.WriteLine(cellElement.ViewTemplate.Caption);
                }
            }

    Translated with www.DeepL.com/Translator
  4. Answer
    Dimitar
    Admin
    Dimitar avatar
    2684 posts

    Posted 21 Mar 2018 Link to this post

    Hi Andre,

    Here is how you can check if the event is fired for a child cell:
    private void RadGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
    {
        if (e.ContextMenuProvider is GridDataCellElement cellElement)
        {
            var cell = e.ContextMenuProvider as GridDataCellElement;
            if (cell.ViewTemplate == radGridView1.Templates[0])
            {
                Console.WriteLine("Child Cell");
            }
           
        }
    }

    Let me know if I can assist you further.
     
    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.
  5. Andre
    Andre avatar
    41 posts
    Member since:
    Feb 2018

    Posted 21 Mar 2018 in reply to Dimitar Link to this post

    hi dimitar
    genau das habe ich gesucht !
    besten dank !
  6. Andre
    Andre avatar
    41 posts
    Member since:
    Feb 2018

    Posted 21 Mar 2018 in reply to Dimitar Link to this post

    hi dimitar
    that's exactly what I was looking for!
    best thanks !
Back to Top