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

Edit cell using tab

20 Answers 413 Views
GridView
This is a migrated thread and some comments may be shown as answers.
venkateshwarreddy
Top achievements
Rank 1
venkateshwarreddy asked on 13 Oct 2008, 06:04 PM
Hi team

Please help me ,Very important task for me .As soon as possible send me sample by tomorrow morning.


currently when we double click only we are getting cell in edit mode  in rad gridview 
requirement:
When using tab and navigating through gridview cells ,the cell  should be in edit mode .


Thank you .

20 Answers, 1 is accepted

Sort by
0
Christopher
Top achievements
Rank 1
answered on 13 Oct 2008, 08:16 PM
As I understand it, the current full release of the WPF RadGridView control does not natively support this this behavior.

I have however implemented this behavior for a project. You'll need to create an EventSetter to handle the KeyDown event of the GridViewCell.

In your KeyDown handler you can capture the tab key presses and move focus to the correct cell and mark it as in edit.  You'll also want to handle Shift + Tab (moving backwards through the cells) as well as moving to the next/previous records.

Be sure to commit the edit in the previous cell before setting the next cell to be in edit mode.  If you don't do this, you'll lose any changes to the previous cells value.

Once you handle the key press be sure to mark the KeyEventArgs has having been handled so the event isn't processed by the GridView control.

The code is a bit lengthy so I have opted not to post it here.

Hope this helps,
  Chris
0
venkateshwarreddy
Top achievements
Rank 1
answered on 14 Oct 2008, 05:13 AM
Hi Christopher,

Thank you for idea ,but can u send me only the code that you have in keydown event  and to commit the edit in previous cell


Please waiting for your reply send me as soon as possible.


Thank you.
0
venkateshwarreddy
Top achievements
Rank 1
answered on 14 Oct 2008, 08:01 AM
Hi Christopher



Please help me send only the event code


Urgent
Thankyou.
0
Christopher
Top achievements
Rank 1
answered on 14 Oct 2008, 12:52 PM
Here is the code.  It has not been refactored in any way yet, as such there is probably a cleaner way to get the job done.

KeyDown handler:
private void Cell_KeyDown(object sender, KeyEventArgs args) 
        { 
            args.Handled = HandleCellKeyPress((GridViewCell)sender,args); 
        } 

HandleCellKeyPress Method:
private bool HandleCellKeyPress(GridViewCell cell, KeyEventArgs args) 
        { 
            Field currentField = cell.Field; 
            int currentFieldID = grid.CurrentRecord.Fields.IndexOf(currentField); 
            int currentRecordID = grid.Records.IndexOf(grid.CurrentRecord); 
 
            if (args.Key == Key.Tab && args.KeyboardDevice.Modifiers == ModifierKeys.Shift) 
            { 
                cell.CommitEdit(); 
                if (currentFieldID > 1) 
                { 
                    grid.CurrentRecord.Fields[currentFieldID - 1].IsCurrent = true
                    grid.CurrentRecord.Fields[currentFieldID - 1].IsInEditMode = true; ; 
                } 
                else 
                { 
                    if (grid.CurrentRecord != grid.Records.First()) 
                    { 
                        grid.CurrentRecord = grid.Records[currentRecordID - 1]; 
                        grid.CurrentRecord.IsCurrent = true
                        grid.CurrentRecord.IsSelected = true
                        grid.CurrentRecord.Fields[3].IsCurrent = true
                        grid.CurrentRecord.Fields[3].IsInEditMode = true
                    } 
                } 
                return true
            } 
            else if (args.Key == Key.Tab) 
            { 
                if (currentFieldID < 3) 
                { 
                    cell.CommitEdit(); 
                    grid.CurrentRecord.Fields[currentFieldID + 1].IsCurrent = true
                    grid.CurrentRecord.Fields[currentFieldID + 1].IsInEditMode = true
                } 
                else 
                { 
                    if (grid.CurrentRecord == grid.Records.Last()) 
                    { 
                        cell.CommitEdit(); 
                        if (AddGas()) 
                        { 
                            grid.CurrentRecord = grid.Records[currentRecordID + 1]; 
                            grid.CurrentRecord.IsCurrent = true
                            grid.CurrentRecord.IsSelected = true
                            grid.CurrentRecord.Fields[1].IsCurrent = true
                            grid.CurrentRecord.Fields[1].IsInEditMode = true
                        } 
                        else 
                        { 
                            currentField.IsCurrent = true
                            currentField.IsInEditMode = true
                        } 
                    } 
                    else 
                    { 
                        grid.CurrentRecord = grid.Records[currentRecordID + 1]; 
                        grid.CurrentRecord.IsCurrent = true
                        grid.CurrentRecord.IsSelected = true
                        grid.CurrentRecord.Fields[1].IsCurrent = true
                        grid.CurrentRecord.Fields[1].IsInEditMode = true
                    } 
                } 
                return true
            } 
            else 
            { 
                return false
            } 
        } 




0
venkateshwarreddy
Top achievements
Rank 1
answered on 14 Oct 2008, 04:05 PM

Hi Cristopher,

I will be thankfull to you for sending me code .
But i am getting errors for this below three lines  that it does not support <>,== operators and addgas() method is what about.

1)if grid .CurrentRecord <> grid.Records.First()
2)if grid.CurrentRecord = grid.Records.Last() Then
3)AddGas()



Please help me to go forward waiting for your reply


yours  faithfully,
venkat


 

 

 

 

0
Christopher
Top achievements
Rank 1
answered on 14 Oct 2008, 04:28 PM
1 and 2 are Linq methods.  Add a using statement for System.Linq.

3. AddGas you will need to rename and code for your application.   That method is adding a new data object to the list the grid is bound to and rebinding the grid. Thus adding a new record.  It returns a boolean result indicating whether the add was successful. 

This is to support adding a new record via tabbing out of the last cell in the last row.  If you do not want to support that functionality simply remove AddGas if block.

Chris
0
venkateshwarreddy
Top achievements
Rank 1
answered on 14 Oct 2008, 05:13 PM
Hi Christoper,

Thank you for your co-operation.

but still i am getting error here
1)Error 1 Operator '<>' is not defined for types 'Telerik.Windows.Data.Record'  

I am getting errors at  the same 2 positions which i mentioned in my previous query.


Please kindly help me so that i may complete my task

Waiting for your reply as soon as possible

Thanking once again.
0
venkateshwarreddy
Top achievements
Rank 1
answered on 14 Oct 2008, 05:25 PM
Hi Christopher,

Sorry I made syntax mistake i corrected it but event is not firing.

my application is hierarchy gridview is this works with both child and parent table with tab.


Thank you .
0
venkateshwarreddy
Top achievements
Rank 1
answered on 14 Oct 2008, 05:34 PM
Hi Christopher,

Forgive me,once again it is my fault .the application is working fine

two issues:
from second cell it is becoming in edit mode.

and i am using hierarchy how to edit for child table cells with tab.


You are great sir,

Thank you very much for ever.
0
Christopher
Top achievements
Rank 1
answered on 14 Oct 2008, 06:09 PM
1) For the issue with the first cell not entering edit mode.  You could try setting a GotFocus handler for the GridViewCell and setting the cell to be in edit mode once it gets focus.  I haven't seen that particular issue in my setup.

2)  I haven't used the RadGridView in a hierarchical way yet.  I'm not sure off hand what changes would need to be made support tabbing from a parent record into a child.  If I get a chance I'll try that later today.

Sorry I don't have a better answer for you right now.

Chris
0
venkateshwarreddy
Top achievements
Rank 1
answered on 15 Oct 2008, 05:55 AM
Hi chris,

Good Morning,

1)Please may you send me focus event code, I am unable to set the field.


2)if you get result for child table tab navigation then send me .

Thanking you
0
venkateshwarreddy
Top achievements
Rank 1
answered on 15 Oct 2008, 10:34 AM
Hi Christopher ,


In property hierarchy When i edit cell using tab the child record are deleting why?

Can you help me


Thank You.
0
Dimitar Dobrev
Telerik team
answered on 15 Oct 2008, 01:25 PM
Hello Venkateshwarreddy,

We can send to you a pre-release build of our product that contains built-in editing by Tab navigation. If you'd like to receive this build, please open a new support ticket and we will upload the files there.

Best wishes,
Dimitar Dobrev,
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
venkateshwarreddy
Top achievements
Rank 1
answered on 15 Oct 2008, 04:30 PM
Hi Team,


I want showgrouppanel for parent table to be enable and for child table to be disable

Thankyou
0
venkateshwarreddy
Top achievements
Rank 1
answered on 15 Oct 2008, 04:40 PM
Hi Christopher,
I have following queries:

Please help me to move forward with my tasks i will be thankful if you give
response as soon as possible.

1)Showgroup panel should be appear for child table and for parent table it should be deleted(rad gridview hierarchy)
2)I want only header text of gridview in different fontsize and fontfamily
for child table as well as for parent table(gridview hierarchy)
for child as well as parent
3)With tab navigation i want to edit child table cell(gridview hierarchy)


waiting for your reply---------------

Thanking you

yours's faithfully

venkateshwarreddy.
0
Dimitar Dobrev
Telerik team
answered on 17 Oct 2008, 12:25 PM
Hello Venkateshwarreddy,

Please refer to this thread.

All the best,
Dimitar Dobrev,
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
ranu
Top achievements
Rank 1
answered on 20 Oct 2008, 01:15 PM
Hi Christopher,

When single click on mouserightclick the cell is editing
but i want with mouseleftclick.

If  you know solution then help me .
Thankyou
0
Atanas
Telerik team
answered on 20 Oct 2008, 02:11 PM
Hi ranu,

This is a know issue for us, I want to assure it will be fixed for our next release.

If you want to receive a pre-released build, please open a new support ticket, since we are not able to post the build in the public forum. Thank you for your understanding and your patience.

Kind regards,
Atanas
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
venkateshwarreddy
Top achievements
Rank 1
answered on 22 Oct 2008, 05:51 AM
Hi Team
Yesterday I registered a support ticket .
I got ID:168993   BUT HOW TO OPEN THIS


PLEASE  REPLY AS SOON AS POSSIBLE
0
Atanas
Telerik team
answered on 24 Oct 2008, 07:25 AM
Hi venkateshwarreddy,

To see your tickets you should log into your Client.net account, go to the menu on the left and select the 'My Support Tickets' item.

Hope this helps.

Sincerely yours,
Atanas
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
venkateshwarreddy
Top achievements
Rank 1
Answers by
Christopher
Top achievements
Rank 1
venkateshwarreddy
Top achievements
Rank 1
Dimitar Dobrev
Telerik team
ranu
Top achievements
Rank 1
Atanas
Telerik team
Share this question
or