How to set focus on first cell of jquery datatable after page loading?
My given code is below:-
What I have tried:
$(document).ready(function () {
var dataTable = $('#hsnGrid').DataTable({
processing: true,
serverSide: true,
orderMulti: false,
searching: false,
paging: false,
scrollX: 200,
scrollY: 300,
keys: true,
ajax: {
url: "/HSN_SAC/LoadItemData",
type: "POST",
datatype: "json",
data: function (data) {
var name = $('#ipTxtSearch').val();
data.ipTxtSearch = name;
},
complete: function (data) {
if (data.responseJSON.hasRowInTable == false)
window.location.href = '/HSN_SAC/Create';
}
},
columnDefs:
[
{
targets: [0],
visible: false,
searchable: false
},
{
targets: [1],
searchable: true,
orderable: true,
width: "50px"
},
{
targets: [2],
searchable: true,
orderable: true,
width:"200px"
},
{
targets: [3],
searchable: false,
orderable: false,
width: "30px"
}
],
columns:
[
{ data: "CodeID", name: "CodeID" },
{ data: "Code", name: "Code" },
{ data: "Name", name: "Name" },
{ data: "Type", name: "Type" }
]
});
});