Hi,
I am trying to read and view a text file while clicking a button in my webix application. The code that I have developed so far looks like below :
toolbar = {
id:'tb',
view: 'toolbar',
height: rowHeight,
type: 'clean',
cols: [
{
view:"button", id:"viewfile",
type:"icon", icon:"external-link",
label:"View Report", width:buttonWidth,
tooltip: "click to view report",
on: {
onItemClick:function(){viewReportFile()}
}
}
]};
function viewReportFile(){
webix.ui( {
view:"window",
height:250,
width:300,
left:50, top:50,
move:true,
resize: true,
head:"This window can be resized",
body:{
template:"Some text"
}
}).show();
}
I have already been able to achieve the same functionality using normal JavaScript and the code for the same is given below :
<input type="file" onchange="onFileSelected(event)">
<br>
<textarea id="result" rows="10" cols="50"></textarea>
<script>
function onFileSelected(event) {
var selectedFile = event.target.files[0];
var reader = new FileReader();
var result = document.getElementById("result");
reader.onload = function(event) {
result.innerHTML = event.target.result;
};
reader.readAsText(selectedFile);
}
</script>
Clicking the ‘View Report’ button , either a pop up window should open up or another tab which will render the content of the file. Is there a way to achieve that, kindly help me. Thanks.