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

cell.GetEditingElement() returns null

6 Answers 53 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Amit Patel
Top achievements
Rank 1
Amit Patel asked on 29 Apr 2011, 04:58 PM
Hello,

I recently updated to the newest released (2011.1.419.1040), and it has broken the application. I have custom column where i am overriding the CreateCellElement(GridViewCell cell, object dataItem) in there i am calling

((

 

TextBox)cell.GetEditingElement()).Text to update the text value, and now i am getting null reference exception. This was working in the previous release. Does anyoen know the workaround for it?

Thanks,
Amit

 

6 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 02 May 2011, 04:35 PM
Hello Amit Patel,

In order to provide you with a more suitable solution, I would need slightly more details. May you share more information about the exact definition of your custom column ? Furthermore, may you verify whether you are getting the same null result for other cells too or just for those of your custom column ?
 

Kind regards,
Maya
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Terry Foster
Top achievements
Rank 1
answered on 02 May 2011, 05:34 PM
The more underlying issue is that the 'GridViewCell' references being passed into the 'CreateCellElement' method are apparently being recycled.  We used to be able to call 'cell.BeginEdit()' on the cell reference passed into this method, and then the cell for which the element was being created would be put into edit mode.  Now, calling 'BeginEdit' appears to try to put a completely different cell into edit mode.  Can you suggest the most appropriate way for us to manually put a cell into edit mode from the 'CreateCellElement' method?  This is an extremely simplied version of what we're trying to do, but seems to illustrate the issue:

public sealed class GridViewDistributionColumn : GridViewDataColumn

 

{

 

 

    public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)

 

 

    {

 

 

 

        var button = new Button();

 

 

        button.Content =

 

"Click Me!";

 

 

        button.Click += (sender, e) => cell.BeginEdit();

 

 

 

        return button;

 

 

    }

 

 

 

}


Thanks,
Terry
0
Maya
Telerik team
answered on 03 May 2011, 03:05 PM
Hi Terry Foster,

If the general purpose is to put the corresponding cell into edit mode, you have to define DataMemberBinding or CellEditElement() / CellEditTemplate. Basically, the reason for you to get null from GetEditingElement() would be that no edit element is created.
Please let me know in case you need any further assistance.
 

Best wishes,
Maya
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Terry Foster
Top achievements
Rank 1
answered on 03 May 2011, 03:11 PM
Our column derives from GridViewDataColumn which already provides a TextBox as the editing element.  Again, this was working before we upgraded to the latest version.  We just want to be able to put the target cell into edit mode in response to the click of a button that is already in the (non-edit mode) cell.

Thanks,
Terry
0
Maya
Telerik team
answered on 04 May 2011, 08:16 AM
Hello Terry Foster,

Indeed, you are quite right - the behavior you mentioned has been changed since Q2 2010 SP2. With the current version you may set the IsTabStop property of the Button to false:

var button = new Button();
button.Content = "Click Me!";
button.IsTabStop = false;
 

Kind regards,
Maya
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Terry Foster
Top achievements
Rank 1
answered on 04 May 2011, 07:19 PM
I got it working.  Thank you.

Terry
Tags
GridView
Asked by
Amit Patel
Top achievements
Rank 1
Answers by
Maya
Telerik team
Terry Foster
Top achievements
Rank 1
Share this question
or