Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
156 views
in Technique[技术] by (71.8m points)

javascript - Is there a way to update selected row data on a datatable?

  • I am trying to change data of a selected row. In my case when a row is clicked it returns the index of that row and then i am trying to update that row with the index of the row i clicked. I can get the index properly, but when i try to update the row it gives an error "Requested unknown parameter 'id' for row 0,column 0".

  • In this case the index that i am trying to update is 0. Here is my code

    var newdata=['data','data2','data2','data4'];

    table.row(0).data(newdata).draw()

question from:https://stackoverflow.com/questions/65662129/is-there-a-way-to-update-selected-row-data-on-a-datatable

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This may help you!

var dtable= $('#example').DataTable();
rowId = 0 ; //first row
newData = [ "column1 data", "column2 data", "column3 data" ] //Array, data here must match structure of table data
dtable.row(rowId).data( newData ).draw();

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...