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

[Solved] Set focus to radGrid after inserting/updating/deleting or refreshing radgrid from client side

2 Answers 228 Views
Grid
This is a migrated thread and some comments may be shown as answers.
muhammad toori
Top achievements
Rank 1
muhammad toori asked on 29 Jan 2010, 12:42 AM
Hi all
I want users to be able to use hot keys to add/update/delete rows to the radgrid. If they are adding a new row as soon as they enter the data and they press ctrl+shift+I they should be able to save the current row and a new row should be inserted where they can continue entering data for the new row. I use fireCommand to perform the insert which works fine but then if i use another firecommand statement to insert an empty row the update fails. What is interesting is that if i place an alert() statement between the 2 fireCommand calls it works in that case. See the javascript function below that i'm using

<

script type="text/javascript">

 


function

KeyPress(sender, eventArgs)

 

{

 

var grid;

 

 

var table;

 

 

grid = sender;

table = grid.get_masterTableView();


 

//CTRL+Shift+I

 

 

if (eventArgs._keyCode == 73 && eventArgs._isCtrlPressed && eventArgs._isShiftPressed)

 

{

 

 

 

eventArgs.set_cancel(

true);

 

 

 

if (table.get_isItemInserted())

 

{

    table.fireCommand(

"PerformInsert", "");
    //alert("now insert another empty row");  

    table.fireCommand("PerformInsert", "");

 

 

 

}

 

}

</

script>

 


Also after any insert/upadate/delete the focus is lost from the grid. How can i set focus back to the radgrid so that the user can continue using arrow keys in the grid. Any assistance will be greatly appreciated!

thanks
mtoori

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Jan 2010, 05:34 AM
Hi,

You need to use InitInsert  as the fireCommand parameter instead of PerformInsert to display a new empty record .
fireCommand("InitInsert", "")

Thanks,
Princy
0
muhammad toori
Top achievements
Rank 1
answered on 29 Jan 2010, 05:17 PM

Hi
I tried fireCommand("InitInsert", ""); but it doesn't work. If i have 2 fireCommand statements one with "PerformInsert" followed by another fireCommand statement with parameter "InitInsert" the update and insert does not work unless i put an alert statement in between the 2 (which i did just to debug)

 

Thanks

 

Tags
Grid
Asked by
muhammad toori
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
muhammad toori
Top achievements
Rank 1
Share this question
or