DubFriend / jquery.repeater

Create a repeatable group of input elements
MIT License
388 stars 191 forks source link

Add items to form repeater from an Excel or CSV file #157

Open ammimounir opened 2 years ago

ammimounir commented 2 years ago

Hi there Is it possible to add a feature where the user can import excel file items to a form repeater before submiting the form to database ? Form repeater is kind of time consuming when it comes to large amount of data (which is my case all the time), in every form we need to input more than 500 rows which are already in a excel file.

Thank You

StreetDog71 commented 2 years ago

You need to split that problem in two. First, gather the data from the CSV file in a javascript array. There are a lot of tutorials and articles on how to do that. Upload the file, read it, parse it, get the data into the array, map it to the repeater fields. Done. After that you can feed that array into the repeater with the setList function.

Say your repeater has the ID my_repeater and your javascript array is named my_js_array. This will get the javascript array into the repeater:

$('#my_repeater').setList(my_js_array);

ammimounir commented 2 years ago

You need to split that problem in two. First, gather the data from the CSV file in a javascript array. There are a lot of tutorials and articles on how to do that. Upload the file, read it, parse it, get the data into the array, map it to the repeater fields. Done. After that you can feed that array into the repeater with the setList function.

Say your repeater has the ID my_repeater and your javascript array is named my_js_array. This will get the javascript array into the repeater:

$('#my_repeater').setList(my_js_array);

How come I didn't think of that !! Thank a lot mate for the tip that helped me a lot.

mrsnax commented 1 year ago

See an example for uploading:

https://github.com/DubFriend/jquery.repeater/issues/81#issuecomment-1336402915