Reputation: 667
I have a dynamic grid in ASP.NET for which the data is being fetched Using Knockout.js, whenever a Search button is clicked. Once the grid is loaded the user can click on the any row to check the details related to that row in a popup.
What I want to implement here is, Once the Search button is clicked and the data in the grid is loaded the focus should be set to the first row and Enter Key should fire the click event (As when clicked by mouse which displays a pop up).
Thanks in advance!!
Note : Using Knockout js and jquery to fetch and bind data in asp.net
Upvotes: 1
Views: 2224
Reputation: 26
Try this:
$(document).ready(function(){
var column = $("#<%=GridView1.ClientID %>").find("tr:eq(1)");
column.focus();
});
If it fails
try
ClientIDMode="Static"
Upvotes: 1
Reputation: 2405
You can use Knockouts hasFocus Binding
The hasFocus binding links a DOM element’s focus state with a viewmodel property. It is a two-way binding, so:
If you set the viewmodel property to true or false, the associated element will become focused or unfocused.
Upvotes: 0
Reputation: 125
$("#search").click(function(){
$("#first-row").focus();
})
//active your row
if( $("#first-row").is(":focus")){
$("#first-row").addClass("active") //maybe a style for this active row
}
$(document).keypress(function(e) {
if(e.which == 13 && $("#first-row").hasClass("active")) {
//redirect or show a div..
}
});
Something like that ?
P.S : I don't know if it's possible to focus a div or tr ^^
Upvotes: 0