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

cellclick from template grid

5 Answers 79 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andre
Top achievements
Rank 1
Andre asked on 18 Mar 2018, 01:13 PM

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

 

thanks

andre

5 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 19 Mar 2018, 11:51 AM
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.
0
Andre
Top achievements
Rank 1
answered on 20 Mar 2018, 02:32 PM
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
0
Accepted
Dimitar
Telerik team
answered on 21 Mar 2018, 09:09 AM
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.
0
Andre
Top achievements
Rank 1
answered on 21 Mar 2018, 06:01 PM
hi dimitar
genau das habe ich gesucht !
besten dank !
0
Andre
Top achievements
Rank 1
answered on 21 Mar 2018, 06:02 PM
hi dimitar
that's exactly what I was looking for!
best thanks !
Tags
GridView
Asked by
Andre
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Andre
Top achievements
Rank 1
Share this question
or