Select the row using the key

Select the row using the key

HordovenkoHordovenko Posts: 24Questions: 2Answers: 0

Hi.
I have a table that works great with Editor and KeyTable. So, I can work just like in Excel, only with the help of a keyboard. But to select the row I must click mouse on the left column. This is not convenient.
Is it possible to make select the row through the key, such as a "Space" for example?
I give a part of the code below.
Thank you.

//...
var table = $('#example').DataTable( {
dom: "Bfrtip",
ajax: {
url: "http://localhost/DataTables/staff.php?nick=" + nick + "&start=" + start,
type: 'POST'
},
// serverSide: true,
columns: [
{
data: null,
defaultContent: '',
className: 'select-checkbox',
orderable: false
},
{ data: "table1.telecast_date" },
{ data: "table1.telecast_time" },
{ data: "table1_telecast_type.type", editField: "table1.telecast_type" },
{ data: "table1.telecast_name" },
{ data: "table1_telecast_genre.genre", editField: "table1.telecast_genre" },
{ data: "table1_telecast_lang.lang", editField: "table1.telecast_lang" },
{ data: "table1_telecast_tak_ni.tak_ni", editField: "table1.telecast_owner" },
{ data: "table1_telecast_tak_ni_ua.tak_ni",editField: "table1.telecast_ua" },
{ data: "table1.telecast_note" },
{ data: "table1.telecast_timing" },
{ data: "table1.nick" },
{ data: "table1.start" }
],
keys: {
columns: ':not(:first-child)',
editor: editor
},
select: {
style: 'os',
selector: 'td:first-child',
blurable: true
},
buttons: [
//...

Replies

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @Hordovenko ,

    This is like your environment here. If you press space anywhere else in the table, it will start editing as keys have been configured. Or did you mean something else?

    Cheers,

    Colin

  • HordovenkoHordovenko Posts: 24Questions: 2Answers: 0

    Hi @colin,
    your example is very good.
    For example, I want to do operation Delete (row). I can assign the key combination to the button "Delete".
    But how can I select the row with the keys (without a mouse) for then call the Delete button?

  • HordovenkoHordovenko Posts: 24Questions: 2Answers: 0

    Hi @allan,
    may be you help me ?
    Thank you.

  • allanallan Posts: 61,653Questions: 1Answers: 10,094 Site admin

    There isn't currently a way to do what you are looking for. As Colin says, space (or other character keys) will activate editing in this sort of case. It would actually be relatively simple to do a binding to select a row (row().select()), but I'm not sure what key / key combination would be suitable!

    Allan

  • HordovenkoHordovenko Posts: 24Questions: 2Answers: 0

    Hi @colin, @allan
    There is a slightly different idea. Select a row when the cell receives focus (when moving using the keyboard). But I can’t realize it.
    Can you help me ? Thank.

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @Hordovenko ,

    Is something like this what you're after?

    Cheers,

    Colin

  • HordovenkoHordovenko Posts: 24Questions: 2Answers: 0

    Hi @colin
    Yes, this is what I need.
    Thank you very much for your help!

This discussion has been closed.