gpt4 book ai didi

javascript - 如何在 webix 应用程序中读取和查看光盘文件

转载 作者:行者123 更新时间:2023-12-03 04:38:02 26 4
gpt4 key购买 nike

我对 webix 开发完全是新手,没有找到太多关于我当前挑战的文档/帮助。

在我的 webix 应用程序中,我希望有一个按钮(名称为“查看报告”),单击该按钮将链接到本地​​光盘中的光盘文件并在弹出窗口中显示其内容。

我包含了到目前为止我可以编写的代码片段:

mytoolbar =
{ id:'tb',
view: 'toolbar',
height: rowHeight,
type: 'clean',
cols: [
{view:"button", id:"showfile", type:"icon", icon:"external-link", label:"View Report", width:buttonWidth, tooltip: "click to view report", on: {onItemClick:function(){viewReportFile()}} },

]

viewReportFile 函数如下所示(摘自 http://docs.webix.com/desktop__window.html )

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();

})
}

单击按钮应读取驻留在我的目录中的文件(假设位于 C:\Users\myname\Desktop\report.txt")并在模式窗口中显示该文件内容。它可以是任何要显示的弹出窗口文件内容带有关闭按钮。任何人都可以帮助我实现吗?我很抱歉无法在此处放置太多代码,因为我是新手。

我还包含一个工作代码,它允许用户从其目录中选择一个文件并在文本区域中显示其内容。

<html>

<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>
</html>

谢谢。

最佳答案

这是一个示例,但请记住,执行此操作的方法有很多种,并且该示例不应最适合您的具体情况:

http://webix.com/snippet/36341f3c

function loadReport() {
return "My report string";
}

function viewReportFile() {
$$('myContent').define('template', loadReport());
$$('myPopup').show();
}


webix.ui({
id: 'myPopup',
view:"window",
height:250,
width:300,
left:50,
top:50,
move:true,
resize: true,
head:"This window can be resized",
body:{
id: 'myContent',
template: "Some text"
}
});

关于javascript - 如何在 webix 应用程序中读取和查看光盘文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43206074/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com