First grid row is not selected when grid's data area gains focus
We have created a sample based on your requirement to select the first row of the Grid on pressing the tab key when focussing the Grid.
Demo Link: http://jsplayground.syncfusion.com/4rsmw2pd
In the above link, we have set the key for firstRowSelection as tab key using the keySettings property of the Grid. Please refer to the below api reference documentation.
http://help.syncfusion.com/js/api/ejgrid#members:keysettings
Refer to the code example.
|
<script type="text/javascript"> $(function () { $("#Grid").ejGrid({ . . . . keySettings: { firstRowSelection: "9, ctrl+36" }, //9- tab key, 36 – home key //by assigning multiple key values for a property in key settings, we can achieve multiple key support for a single operation }); </script> |
Regards,
Ragavee U S.
We have prepared a sample based on your requirement to unselect the record when grid losts focus and select the record when gains focus.
Demo Link: http://jsplayground.syncfusion.com/jzhgjgof
In the above sample, we have saved the selectedRowIndex in a global variable and have cleared selection in grid upon focussing out the grid element. In focusin event of the grid, we have passed the index to the selectRows method of the ejGrid.
Please refer to the below code example.
|
<script type="text/javascript"> $(function () { var index = 0; $("#Grid").focusin(function (e) { //focusin event of the grid index = index == -1 ? 0 : index; $("#Grid").ejGrid('selectRows', index); //select the row }) $("#Grid").ejGrid({ . . . . dataBound: function () { this.element.focusout(function () { //focus out event of the grid index = $("#Grid").ejGrid('model.selectedRowIndex'); //save the selectedRowIndex in a variable $("#Grid").ejGrid('clearSelection'); //perform clear selection }) },
});
});
|
Regards,
Ragavee U S.
- User selects a row.
- User clicks away from the grid.
- User clicks back onto the grid (but selects a different row).
Attachment: gridclicking_5da887d8.zip
We have analyzed your issue "highlights the previously selected row before selecting the new row" and we found that the focusin event get triggered while selecting the row by using “mouse” also. So that only the previous row always selected while select the row using mouse.
We can resolve the above issue by using below code example,
|
$(function () { var index = 0,isClick; //Binding click event to the grid $("#Grid").bind('click', function () { isClick = true; }) //Binding keyup event to the grid .bind('keyup', function (e) { if (e.which == 9) { isClick = false; } }); var focusHandler = function () { //prevent the record selection if the row selected through mouse clicked if (!isClick) { index = index == -1 ? 0 : index; $("#Grid").ejGrid('selectRows', index); } } $("#Grid").on("focusin", function (e) { //Timeout for triggering click and keyup events setTimeout(focusHandler, 200); });
});
|
We have created modified a sample and it can be referred from below link,
http://jsplayground.syncfusion.com/alug2q5d
Regards,
Gowthami V.
We have modified the sample resolving the reported issues, which can be downloaded from the below location.
Demo Link: http://jsplayground.syncfusion.com/40nfndt3
In the above sample, we have removed the tabindex attribute for the toolbar element in the jquery focusout event of the Grid. Please refer to the below code example.
|
dataBound: function () { this.element.focusout(function () { index = $("#Grid").ejGrid('model.selectedRowIndex'); $("#Grid").ejGrid('clearSelection'); $("div.e-gridtoolbar").removeAttr("tabindex"); } ) |
Regards,
Ragavee U S.
We considered this query “When tab key trigger from Grid content both Toolbar and Grid gets focused” as a bug and a support incident has been created under your account to track the status of this issue. Please log on to our support website to check for further updates.
https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents
As of now, we have prepared a workaround inorder to handle the above issue.
Demo Link: http://jsplayground.syncfusion.com/nnhkhr1f
In the above sample, we have prevented the row selection when the toolbar icons gains focus using a flag variable. Please refer to the below code example.
|
var focusHandler = function () { if (document.activeElement.id == "Grid_toolbarItems") flag = 1; else flag = 0; if (!isClick && flag == 0) { index = index == -1 ? 0 : index; $("#Grid").ejGrid('selectRows', index); }
|
Regards,
Ragavee U S.
If the grid gains focus, then the first row will not be selected. This is the behavior of the navigation keys. In order to select the first row on grid focus, we suggest you to use the keySettings property of the Grid.
But we considered this query “When grid gains focus, pressing the up/down navigation keys should navigate up or down the grid records” as a usability feature and a support incident has been created under your account to track the status of this feature.
It is the default behavior of any control to maintain its status when the control looses its focus. So it is not a proper approach to clear selection upon focusing out the grid control. But we have considered “Lighten the background color of the selected record when grid lost focus” as a usability feature and a support incident has been created under your account to track the status of this feature.
Please log on to our support website to check for further updates.
https://www.syncfusion.com/account/login?ReturnUrl=/support/directtrac/incidents
Regards,
Ragavee U S.
Thanks for the update. Please follow up the incident for further updates.
Regards,
Ragavee
- 13 Replies
- 3 Participants
-
GG Greg Gannicott
- Feb 5, 2016 11:01 AM UTC
- Feb 26, 2016 06:02 AM UTC