data table row select item to input text

data table row select item to input text

setintsetint Posts: 5Questions: 1Answers: 0

Hi
Data Table version 1.11.3
I want select item in table to input text write. How I do?
Thank you.

Answers

  • rf1234rf1234 Posts: 2,143Questions: 67Answers: 310

    Use Editor with inline editing.

    Here is an example and you'll find many more in the docs:
    https://editor.datatables.net/examples/inline-editing/simple.html

  • setintsetint Posts: 5Questions: 1Answers: 0

    Thank you @rf1234 .
    But I want table select row items send to inputteexts
    Samle
    <input type="text" id="t1" />
    <input type="text" id="t2" />
    <input type="text" id="t1" />
    from table selected >>>>>to input

  • kthorngrenkthorngren Posts: 15,760Questions: 25Answers: 3,736

    Are you saying you want a table like this?
    https://datatables.net/examples/plug-ins/dom_sort.html

    Kevin

  • rf1234rf1234 Posts: 2,143Questions: 67Answers: 310
    edited January 23
    var selected = yourDataTable.row({selected: true});
    $('#t1').text(selected.data().t1);
    $('#t2').text(selected.data().t2);
    

    assuming t1 and t2 are the names of the respective columns in the data table.

    If you want to do this when a row in the data table is being selected you can use this event:

    yourDataTable
        .on ( 'select', function (e, dt, tp, indexes) {
            var selected = dt.row({selected: true});
            $('#t1').text(selected.data().t1);
            $('#t2').text(selected.data().t2);
        } );
    
  • setintsetint Posts: 5Questions: 1Answers: 0
    edited January 23

    Dear Sear @rf1234

    Sory; I'm don't

    1. My inputs:
      <input type="number" id="t1" required />
      <input type="text" id="t2" required />
      <input type="text" id="t3" required />

    My table id= "table1"
    field = t1, t2, t3
    Now
    I selected table1 row. Row field transfer t1,t2,t3

    Your scrip

    var selected = table1.row({ selected: true }); $('#it1').text(selected.data().t1); $('#t2').text(selected.data().t2); $('#t3').text(selected.data().t3); icd10 .on('select', function (e, dt, tp, indexes) { var selected = dt.row({ selected: true }); $('#t1').text(selected.data().t1); $('#t2').text(selected.data().t2); $('#t3').text(selected.data().t3); });

    BUT NOT WORK . please can you help me? Thank you

  • kthorngrenkthorngren Posts: 15,760Questions: 25Answers: 3,736

    Are you using the Select extension? It is required for the above code.

    If you still need help please build a test case showing what you have so we can provide specific help.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • kthorngrenkthorngren Posts: 15,760Questions: 25Answers: 3,736

    I added the Select extension library. See the HTML tab. I updated the code to show populating the value of a text input from the data in the selected row.
    http://live.datatables.net/vozezumi/2/edit

    Kevin

  • setintsetint Posts: 5Questions: 1Answers: 0
    edited January 23

    Thank you very much you and @rf1234 is very good experts. Loves from Turkey.

Sign In or Register to comment.