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

Lost focus

7 Answers 149 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dennis
Top achievements
Rank 1
Dennis asked on 23 Apr 2013, 09:13 PM
I have a grid view with editable text box and a button ("PRINT")  in it (with data binding).
When I edit a text in the text box and then press the button the text in the text box doesn't get updated , the text box doesn't lose focus on the button click...
So for example : when the form loaded the text box contains text "AAA". I click on the text box and start changing the text to "BBB", then (without diselecting the text box) I click "PRINT" button  - the printed value would be "AAA" and not "BBB"


<telerik:GridViewDataColumn  DataMemberBinding="{Binding LabelToPrint, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"   Header="label " IsReadOnlyBinding="{Binding IsLabelReadOnly}" EditTriggers="CellClick" >
                                </telerik:GridViewDataColumn>
                                <telerik:GridViewColumn Header="Print Label" FocusManager.FocusedElement="BagGridView">
                                    <telerik:GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <telerik:RadButton Content="Print Label"  Command="{Binding DataContext.PrintLabelCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:RadGridView}, AncestorLevel=2}}" CommandParameter="{Binding}"/>
                                        </DataTemplate>
                                    </telerik:GridViewColumn.CellTemplate>
                                </telerik:GridViewColumn>

7 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 24 Apr 2013, 06:14 AM
Hello Dennis,

You can try to execute the RadGridView.CommitEdit method just before printing the value.

I hope this helps.

Greetings,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Dennis
Top achievements
Rank 1
answered on 24 Apr 2013, 01:08 PM
Hi
Unfortunately it hasn't resolved the issue
I added RadGridView.CommitEdit() on PRINT button's click, but nothing has changed. After the click the text boxed still continued to keep the focus and remains editable....
Here is a video to illustrate the issue
http://www.screenr.com/Kl57
Thanks
0
Yoan
Telerik team
answered on 26 Apr 2013, 02:55 PM
Hi Dennis,

Indeed, you are quite right. I am afraid that this is expected behavior. However, I can suggest you to implement a functionality similar to this demo

Regards,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Dennis
Top achievements
Rank 1
answered on 26 Apr 2013, 03:04 PM
Hi
I don't think it shoud be expected as a standard behaviour.When another control (button in this case) is clicked , the text box should lose the focus and commit any performed changes. The workaround we've implemented so far  is to use a regular text box control inside of RAD datacolumn with PropertyChanged for UpdateSourceTrigger...
0
Yoan
Telerik team
answered on 01 May 2013, 09:21 AM
Hi Dennis,

I am glad to hear that you could resolve the problem by yourself.

All the best,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
gaurav
Top achievements
Rank 1
answered on 12 Aug 2019, 09:25 PM

has this functionality been implemented yet or is it still a bug in the system. As pointed above, the expected behaviour should be lose focus and I was wondering that its been 6 years since an issue was reported and whether it has been incorporated in Radgrid yet?

 

0
Martin Ivanov
Telerik team
answered on 15 Aug 2019, 02:48 PM

Hello Gaurav,

The focus is not lost when you click the button because the RadGridView control was designed this way. Basically, nothing can get the focus until the currently edited cell exit the edit mode. This was implemented to avoid invalid data back to the model and therefore the validation to work properly. 

To achieve the behavior asked in the original post of this reply, you can manually commit the edit when the button gets clicked. I've attached a small example showing this approach. I hope it helps.

Regards, Martin Ivanov
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.
Tags
GridView
Asked by
Dennis
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Dennis
Top achievements
Rank 1
gaurav
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or