Knockout JS: Get Textbox data from Table under for-each binding

42 views
Skip to first unread message

kaka

unread,
Mar 27, 2018, 2:27:49 PM3/27/18
to KnockoutJS

Using knockout js here:

Following on from my post at Knockout JS: Creating dynamic table columns

I have managed to somehow create dynamic columns in knockout. So when the user clicks add row it adds a row to the table. What I am currently stuck is at how to get the data with what is entered in the textboxes in my table. Say for ex I have 4 columns and adding a row would create 4 textbox in the table. When the user enters the data in those textbox I want to loop and get all the data that is entered and save.

Here is the jsfiddle that I have managed to create. https://jsfiddle.net/aman1981/L3pjhk0z/6/

My valuesData is always empty here:

"valuesData": [
{}

What updates do I need to make in my fiddle to get all the data. May be in the json form as

{
  "col1": "1", 
  "col2": "2"
   ....and so on depending on the columns
} 
Reply all
Reply to author
Forward
0 new messages