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

Batch Editing - Using Tab Key

1 Answer 216 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Developer
Top achievements
Rank 1
Developer asked on 05 Nov 2018, 01:57 PM

Hello,

I have a RadGrid with batch editing enabled.  The columns are a mixture of GridDataboundColumn and GridTemplateColumn

At the moment its configured that edit changes are saved whenever the cell being edited looses focus.

I would like to get to the point where I can have a user make an edit, then once they’ve hit the tab key it saves the cell and then moves focus to the next editable cell in the row.

I’ve enabled KeyboardNavigation but each time the grid saves its looses its place so that tab does not work.

Is this possible – Can you provide an example please?
 


1 Answer, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 07 Nov 2018, 03:40 PM
Hello,

The purpose of the Batch editing is to allow multi-line editing and perform multiple changes before the user decides to save the data. Its intention is to gather all the changes and send a request to the server only once, containing all the relevant data. 

Implementing a functionality to send the edited data the moment a cell loses focus serves the exact opposite purpose of Batch editing. Creating the logic for such behavior would be burdensome work. 

If having such behavior is a must-have, then you might opt for using a RadSpreadsheet or to make use of TemplateColumns and send the data to the server on the blur event of the controls inside the template.

If wish to open the next cell for editing when a key is pressed, (e.g., using Tab), you can try attaching the KeyDown event to the grid in the PageLoad() event handler:

protected void Page_Load(object sender, EventArgs e)
{
    RadGrid1.Attributes.Add("onKeyDown", "onKeyDown(event)");
}

Then customize the following handler according to your needs. You can check out the Batch Editing Client-side API for more information on working with batch editing.

function onKeyDown(e) {
    var grid = e.target.control;
      
    if (e.keyCode == 9 && !e.shiftKey || e.keyCode == 39) {
        // if either ArrowRight or TAB is pressed
        e.preventDefault();
        // Find the next cell and open it for editing
        }
    } else if (e.keyCode == 9 && e.shiftKey || e.keyCode == 37) {
        // if either ArrowLeft or SHIFT+TAB is pressed
  
         // Find the previous cell and open it for editing
 
    }
}

Attached, you can find a sample with the aforementioned approach implemented. 

Also, attached you can find a project with saving changes without clicking the Save Button. Hence, the changes take place when the OnChange event is called. Note that this is a rather custom solution and Telerik does not bear responsibility for performance implications or any misbehavior that might occur. 

With the help of Client-Side Programming and Batch Editing API you can customize the projects/approaches to meet your requirements.

Let me know if you need further clarification.

Kind regards,
Tsvetomir
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
Grid
Asked by
Developer
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Share this question
or