Hi,
I can insert data into the server via web API, but l have no idea how to insert picture as i have search for several hours about this but was not able to find any useful materials. For instance, I have EmployeeId, EmployeeName, PhotoOfEmployee,
How to insert Picture of each employee into the server using observables method? Kindly assist
Hi,
I was not able to make use of the image preview method provided among the documentations mentioned by you as l don't know how to create it in grid dialog. So, I have used the normal uploader. The uploader is working fine but l want it to be bind with EmployeeId so that when l want to edit a record in the grid it would be populated by calling EmployeeId. Below are the codes that l have tried. Kindly assist
Hi Charles,
You can get the currently edited row data using "state.rowData" inside the “write” method. Using this you can customize the Uploader component as per your requirement.
|
write: (state) => { alert(state.rowData.EmployeeID); this.uploadObj = new Uploader({ . . . }); this.uploadObj.appendTo(this.elem); . . . };
|
If this does not meet your requirement, please share the below details that will be helpful for us to provide a better solution as early as possible.
Regards,
Pavithra S
Hi Pavithra,
1. I don't want the uploader to auto upload image into the folder Photos at the backend. I want to manually upload image as soon as the grid save button is clicked. When l click the save button l want it to save all the data in the field i.e. EmployeeId, EmployeeName, Department, DOB, PhotoFileName at once into the server.
2. Yes l also want to show the image for the corresponding EmployeeId while editing
Hi Charles,
Thanks for sharing the details.
Query#1: I want to manually upload image as soon as the grid save button is clicked. When l click the save button l want it to save all the data in the field i.e. EmployeeId, EmployeeName, Department, DOB, PhotoFileName at once into the server.
You can achieve your requirement by setting the “autoUpload” property of the uploader component as “false”.This will restrict the file uploading. And you can get the selected file information inside the “selected” event handler. So you can store this information in a variable and set it to the edited data inside the “actionComplete” event with “save” requestType. Please refer to the below code example and API link for more information.
|
this.editparams = { . . . write: (state) => { this.uploadObj = new Uploader({ asyncSettings: { saveUrl: 'http://localhost:5000/api/Employee/SaveFile', removeUrl: 'http://localhost:5000/api/Employee/SaveFile', }, autoUpload: false, selected: select.bind(this), success: onUploadSuccess.bind(this), failure: onUploadFailure, }); this.uploadObj.appendTo(this.elem); function select(args) { this.uploadedFile = args.filesData[0]; } }, }; . . . actionBegin(args) { if (args.requestType == 'save') { this.uploadObj.upload(); args.data['PhotoFileName '] = this.uploadedFile.name; } }
|
API : https://ej2.syncfusion.com/angular/documentation/api/uploader/#autoupload
https://ej2.syncfusion.com/angular/documentation/api/uploader/#selected
https://ej2.syncfusion.com/angular/documentation/api/uploader/#upload (for manually uploading the file)
https://ej2.syncfusion.com/angular/documentation/api/grid/#actioncomplete
Query#2: Yes l also want to show the image for the corresponding EmployeeId while editing
Before providing a solution, please share the format of the image (ex: base64 or file location) that will be helpful for us.
Regards,
Pavithra S
Hi Pavithra,
It's still didn't work.
Nevertheless, I want to work with forms and will like to achieve exactly (inputs, image uploader, and panels) that is shown on the picture attached. I don't want to make use of the grid/grid dialog. I want to create form with fields that save data to the server. Am using syncfusion angular. Kindly assist
Hi Charles,
Regarding your query with Syncfusion inputs and uploader components, we have created a new ticket under your account. So please follow that ticket for more updates.
Regards,
Pavithra S