Page 1 of 1
Related item, limit number of files in drag drop
Posted: 07 Apr 2017
by metrovan
Hi,
I have a related item form, and I'd like to limit the number of files that can be dragged and uploaded at one time.
For example, limit to 10 files at a time, if the user tries to drag 15, it will stop the upload and show a message about the limit?
Thanks.
Re: Related item, limit number of files in drag drop
Posted: 10 Apr 2017
by Dmitry Kozlov
Hi,
You can check the number of rows in the Related Items with JavaScript:
Code: Select all
fd.relatedItems(0).data('ctx').ListData.Row.length
If it exceeds a limit, notify a user by alerting or displaying a notice somewhere in the form.
Re: Related item, limit number of files in drag drop
Posted: 10 Apr 2017
by metrovan
Thanks Dimitry,
I don't want to set a limit on the related items list. I want to set the number of files limit to 10 at each time.
I want to set a limit because I am using the fd.updateDroppedDocuments function to update some data to the related item. I will have users who like to drag 80 files at a time, and not all of the related will get updated with the proper data only the first few.
Is there a way to make sure all of the files will have the proper data updated?
thanks.
Re: Related item, limit number of files in drag drop
Posted: 11 Apr 2017
by Dmitry Kozlov
Right, you can check the number of already uploaded documents and notify a user that he cannot upload more. To check the number of docs on the client side, use the code:
fd.relatedItems(0).data('ctx').ListData.Row.length
Re: Related item, limit number of files in drag drop
Posted: 11 Apr 2017
by metrovan
Hi Dimitry,
This will not work if there are already 10 files in the relateditem list. I want to let the user to keep uploading to the list but only max 10 items at a time.
Is there a way to check how many files there are in the 'drop' action, before the upload begins?
Re: Related item, limit number of files in drag drop
Posted: 12 Apr 2017
by Dmitry Kozlov
Aha, now I see. User cannot attach more than 10 docs at a time. The easiest solution is adding a notice onto the form: please, upload no more than 10 documents. Checking the number of dropped docs will require a deep research of the SharePoint grid and its events. I'm afraid it will take about 3 support hours.