is there an onselect event in the select extension
is there an onselect event in the select extension
izumov
Posts: 178Questions: 14Answers: 0
is there an onselect event in the select extension that occurs when I select a row? I need to handle this event
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Here are the select events:
https://datatables.net/reference/event/#select
Depending on your needs you will want either
select
oruser-select
.Kevin
Please see my code I have why the handler does not work when you select a line
$('#orders').on( 'select', function ( e, dt, type, indexes ) {
if ( type === 'row' ) {
kod=table.rows( {selected:true} ).data();
kodorder=kod[0][0];
alert('orders kod is:'+kodorder);
}
});
What exactly is not working?
I think this is incorrect
$('#orders').on(
. Try$('#orders').DataTable().on(
to get an API instance.If this doesn't help then please post a link to your page or a test case so we can see what you have.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
@izumov : please can you only put the triple-back ticks before the first line of code, and after the final line of code - not on every line. Thanks.
why wasn't my question posted yesterday?
?
I asked how to access the first column of the selected row in the handler because my code was not functional .My cod:
This is a row that is only is selecting and at the time of the handler's operation as far as I understand is not selected
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
Here is my test case
http://montaj.vianor-konakovo.ru/orders024.html
An error occurs when you select a row
Cannot read property '0' of undefined
It's because you haven't defined
table
- if you changetable
to bedt
(it's provided in the callback) on lines 3 and 4 above, everything works fine.Thanks for the hint now the code works correctly.