H
H
hollanditkzn2017-05-16 18:24:01
Yii
hollanditkzn, 2017-05-16 18:24:01

How to implement row clickability in grid?

I need to implement so that view?id=$id opens when clicking on a row in the grid. An example I understood how to do is to receive data-key in it, as I understand it, because they fit the id.
Understanding how to redirect by link is not clear how to do it correctly, so I indicated the full path

$(document).ready(function(){
  $('tr').on('click', function(){
    var key = $('tr').data('key');
    document.location.href = "http://crm/frontend/web/zakaz/view?id="+key;
  });
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-05-16
@hollanditkzn

$('tr')are all tr. And you need the one that got the click. Therefore, instead $('tr').data('key');of$(this).data('key');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question