BoldDesk®Customer service software offering ticketing, live chat, and omnichannel support, starting at $49/mo. for 10 agents. Try it for free.
Hi Team,
Hope all good.
Query 1:
I want to select files using File Uploader control and selected files name and modified date of file details to be added in TreeGrid control.
Query 2:
Is it possible to add a folder(which has multiple file) instead of select a files in Uploader control?
Query 3:
How to customize(Color, Font, Font Size etc...) the Browser button in Uploader control?
let dropElement: HTMLElement = document.getElementsByClassName('control-fluid')[0] as HTMLElement;
// Initialize the uploader component
let uploadObj: Uploader = new Uploader({
asyncSettings: {
saveUrl: 'https://ej2.syncfusion.com/services/api/uploadbox/Save',
removeUrl: 'https://ej2.syncfusion.com/services/api/uploadbox/Remove'
},
dropArea: dropElement,
directoryUpload: true
});
uploadObj.appendTo('#fileupload');
|
.e-upload .e-file-select-wrap .e-btn{
font-family: emoji;
font-size: 15px;
color: darkorchid;
background-color: bisque;
}
|
let uploadObj: Uploader = new Uploader({
asyncSettings: {
saveUrl: 'https://ej2.syncfusion.com/services/api/uploadbox/Save',
removeUrl: 'https://ej2.syncfusion.com/services/api/uploadbox/Remove'
},
dropArea: dropElement,
directoryUpload: true,
buttons: {
browse: 'Choose file',
}
});
uploadObj.appendTo('#fileupload');
|
<button onclick="add()">Add record</button>
<div id="TreeGrid"></div>
<script>
function add() {
var treegrid =
document.getElementsByClassName('e-treegrid')[0].ej2_instances[0];//treegrid instance
var data = {
taskID: '100',
taskName: 'test',
};
treegrid.addRecord(data, 0, 'Above');
}
</script>
|
can i do it using fetch API ?
Hi Deepak ,
Thanks for your response.
Query 1 response is inappropriate. Why you are using button control to add the data in TreeGrid. I clearly mentioned to add the data using file uploader control.
My Scenario is.
- I want to show the File Uploader control like normal button.
- When I click the button, file manager will open and select wanted files.
- Add selected file details(such as Filename, Size) to the TreeGrid.
- Mean while I want also to download and delete the files from TreeGrid.
let uploadObj: Uploader = new Uploader({
asyncSettings: {
saveUrl: "http://localhost:58812/Home/Save",
removeUrl: 'http://localhost:58812/Home/Remove'
},
removing: onFileRemove,
dropArea: dropElement,
showFileList: false,
success(args){
console.log(uploadObj.getFilesData());
treeGridObj.dataSource = uploadObj.getFilesData();
},
});
|
let onSave = (args: Event) => {
var fileName = args.target.parentElement.parentElement.parentElement.parentElement.getElementsByClassName('e-rowcell')[1].innerText
if(fileName)
{
let url = "http://localhost:58812/Home/Download?filename=" + fileName;
window.location.rel='nofollow' href = url;
fileName = null;
}
};
|
[HttpGet]
public FileResult Download(string filename)
{
var filePath = Path.Combine(
Directory.GetCurrentDirectory(),
"wwwroot");
IFileProvider provider = new PhysicalFileProvider(filePath);
IFileInfo fileInfo = provider.GetFileInfo(filename);
var readStream = fileInfo.CreateReadStream();
var mimeType = "application/pdf";
return File(readStream, mimeType, filename);
} |