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

GridViewCheckBoxColumn

4 Answers 197 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Muhammad Naveed
Top achievements
Rank 1
Muhammad Naveed asked on 26 Aug 2017, 05:25 AM

I want to add a condition on GridViewCheckboxColumn click event, requirement is 'when checkbox is clicked event should be fired.'

Currently i applied GridViewCell_Click event but it fired on current Cell not particularly on checkbox, and i don't want to use Cell_ValueChanged event according to my programming scenario because it reflects a lot of change in my code.

What should i do?

c# programming language

4 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 28 Aug 2017, 08:47 AM
Hi Muhammad,

Thank you for writing.

Note that most of the forum threads are reviewed by Telerik representatives. However, a post in the forum doesn't guarantee you a response from the Telerik support team. If you think that Telerik needs to review your project and/or files, start a new support ticket.

Regarding your actual question, if I understand you correctly you would like to detect clicks on the check mark. You can achieve your task by handling the MouseDown event of the grid: 
private void RadGridView1_MouseDown(object sender, MouseEventArgs e)
{
    RadGridView grid = (RadGridView)sender;
    RadCheckmark checkMark = grid.ElementTree.GetElementAtPoint(e.Location) as RadCheckmark;
    if (checkMark != null)
    {
        //...
    }
}

I hope this helps. Should you have further questions please do not hesitate to write back.

Regards,
Hristo
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Muhammad Naveed
Top achievements
Rank 1
answered on 29 Aug 2017, 06:06 AM

Hi Hristo,

Thanks for your reply.

I tried same code but same result received,

my scenario is i would like to update the datetime when checkbox is clicked on that particular cell grid. currently it updates the datetime even when i clicked on a cell not on checkbox.

0
Accepted
Hristo
Telerik team
answered on 29 Aug 2017, 11:47 AM
Hi Muhammad,

Thank you for writing.

The code snippet I sent you performs a check for the RadCheckMark type. The if statement will be evaluated to true only when clicking on the check mark. 

I have extended the example to demonstrate how you can get the logical row object and change any of the other cell values when clicking on the checkbox: 
private void RadGridView1_MouseDown(object sender, MouseEventArgs e)
{
    RadGridView grid = (RadGridView)sender;
    RadCheckmark checkMark = grid.ElementTree.GetElementAtPoint(e.Location) as RadCheckmark;
    if (checkMark != null)
    {
        GridDataRowElement row = checkMark.FindAncestor<GridDataRowElement>();
        if (row != null)
        {
            GridViewCellInfo dateCell = row.RowInfo.Cells["Date"];
            DateTime dt = ((DateTime)dateCell.Value).AddDays(1);
            dateCell.Value = dt;
        }
    }
}

I am also attaching a short video showing the result on my end.

I hope this helps. Please let me know if you have other questions.

Regards,
Hristo
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Muhammad Naveed
Top achievements
Rank 1
answered on 30 Aug 2017, 06:25 AM

Thanks Hristo for a usefull reply. 

Tags
GridView
Asked by
Muhammad Naveed
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Muhammad Naveed
Top achievements
Rank 1
Share this question
or