jQWidgets Forums
jQuery UI Widgets › Forums › Grid › jqxGrid('focus') does not work in Chrome
Tagged: jqxgrid, jqxGrtid sellectcell
This topic contains 3 replies, has 2 voices, and was last updated by Peter Stoev 11 years, 5 months ago.
-
Author
-
Hello,
I need to select one cell of the grid when page is loaded.
I use the code(function ($) { var dataUrl = '@Url.Action("GetCityData")'; var gridSelector = "#cityGrid"; $(document).ready(function () { var source = { datatype: 'json', dataFields: [ { name: 'id', type: 'Number' }, { name: 'name', type: 'String' }, { name: 'population', type: 'Number'}, { name: 'year', type: 'Number' }, { name: 'country', type: 'String' } ], url: dataUrl, id: 'id' }; var dataAdapter = new $.jqx.dataAdapter(source); $(gridSelector).jqxGrid({ source: dataAdapter, selectionmode: 'singlecell', theme: 'classic', columns: [ { text: 'Name', dataField: 'name', width: 150 }, { text: 'Foundation Year', dataField: 'year', width: 150 }, { text: 'Population', dataField: 'population', width: 200 }, { text: 'Country', dataField: 'country' } ] }); setTimeout(function () { $(gridSelector).jqxGrid('selectcell', 0, 'name'); $(gridSelector).jqxGrid('focus'); }, 5); }); })(jQuery);
But it works well only in Internet Explorer. In Chrome the cell is selected, but grid has no focus and keyboard navigation does not work. What should I do to deal with this problem?
Thanks
Hi alex_svs_fl,
You do it incorrectly. ‘selectcell’ and ‘focus’ should be called within the Grid’s ready callback or within the Grid’s bindingcomplete event handler. Otherwise, you will try to focus element which is not created.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comPeter, thanks for answer. I have changed my code and placed the code $(gridSelector).jqxGrid(‘selectcell’, 0, ‘name’);
$(gridSelector).jqxGrid(‘focus’); to ready() function in the grid initialization. But nothing has been changed, Chrome continues to work without focus on the required cell.Hi alex_svs_fl,
You are right. I am sorry for my previous response. It seems that I missed that. I will create a work item for the reported issue. The focus seems to be put only after you Click within the Grid, but the method does not work correctly in Chrome for some reason. We will do our best to fix that.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.