- Home
- Forum
- ASP.NET MVC
- Allow Editing with double click mode not working
Allow Editing with double click mode not working
Thanks for contacting Syncfusion Support.
From the code snippets that you have shared we found that you have enabled BatchEditing feature in grid. Batch editing feature is similar to that of Excel-like editing. So once a cell is clicked, it changes to editable state and thus can be modified.
Since the editing operation occurs in single mouse click event, AllowEditOnDblClick won’t work in batch editing as it is the default behavior. So we suggest you to use either one option(AllowEditOnDblClick or BatchEditing) in your sample in order to get better user interaction.
If you still face any difficulties, please get back with more and clear details such that we can assist you accordingly.
Regards,
BalajI Marimuthu
Batch editing feature is similar to that of Excel-like editing. So once a cell is clicked, it changes to editable state and thus can be modified. Since the editing operation occurs in single mouse click event, AllowEditOnDblClick won’t work in batch editing as it is the default behavior.
But, we can achieve your requirement using the workaround solution and please refer to the code example as below.
Sample: MvcApplication1
|
(Html.EJ().Grid<object>("FlatGrid") .Datasource((IEnumerable<object>)ViewBag.datasource) .EditSettings(e => e.AllowEditing().AllowDeleting().AllowAdding().EditMode(EditMode.Batch).AllowEditOnDblClick(true)) .AllowPaging() .Columns(col => { col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add(); col.Field("EmployeeID").HeaderText("Employee ID").EditType(EditingType.Dropdown).TextAlign(TextAlign.Right).Width(75).Add(); col.Field("Freight").HeaderText("Freight").EditType(EditingType.Numeric).TextAlign(TextAlign.Right).Width(75).Format("{0:C}").Add(); col.Field("ShipCity").HeaderText("Ship City").Width(110).Add(); }) .ClientSideEvents(eve=> eve.Create("create").CellEdit("celledit").RecordDoubleClick("dblclick")) )
|
In Create event we bound the double click handler to Grid content to enable the double click event. In RecordDoubleClick event we prevent the default operation by setting the args.cancel as true and edit the particular cell using editCell method. Refer to the help document as below.
http://help.syncfusion.com/js/api/ejgrid#methods:editcell
|
<script type="text/javascript">
function create(args) { this._on(this.element, "dblclick", ".e-gridcontent", this._editdblClickHandler); //enable double click event }
function dblclick(args) { args.cancel = true; // prevent default operation this._dblclick = true; this.editCell(args.rowIndex, this.getColumnByIndex(args.cellIndex)["field"]); //trigger editcell }
function celledit(args) { !this._dblclick ? args.cancel = true : this._dblclick = false; } |
The CellEdit event triggers for every record cell edit and we have prevented the default operation when perform the single click edit operation.
http://help.syncfusion.com/js/api/ejgrid#events:celledit
Refer to the document for Create and RecordDoubleClick events:
http://help.syncfusion.com/js/api/ejgrid#events:create
http://help.syncfusion.com/js/api/ejgrid#events:recorddoubleclick
Regards,
Balaji Marimuthu
Based on your requirement we have modified the code example with keyboard navigation. Refer to the sample and code example as below.
Sample: Sample-BatchDblClick
|
<script type="text/javascript">
function create(args) { this._on(this.element, "dblclick", ".e-gridcontent", this._editdblClickHandler); //enable double click event }
function dblclick(args) { args.cancel = true; // prevent default operation this._dblclick = true; this.editCell(args.rowIndex, this.getColumnByIndex(args.cellIndex)["field"]); //trigger editcell }
function celledit(args) { if (!this._dblclick && !this._extkey) args.cancel = true; //prevent default operation for single click else { this._dblclick = false; this._extkey = false; } }
$("#FlatGrid").keydown(function (e) { var obj = $("#FlatGrid").ejGrid("instance"); if (e.keyCode == 9 || e.keyCode == 38 || e.keyCode == 40) { if (e.keyCode != 9) e.target.select(); obj._extkey = true; } else obj._extkey = null; }) |
In CellEdit event we have prevented the default operation for single click. Please let us know if you have any concerns.
Regards,
Balaji Marimuthu
- 6 Replies
- 4 Participants
-
CM Carlos Mattos
- Dec 11, 2015 12:33 PM UTC
- Jan 5, 2016 06:51 AM UTC