javascript - webix 数据表按列到行

标签 javascript webix

嘿,大家好,我在 webix 中遇到一个问题,我想按行显示,但我无法找到如何以这种方式显示它,我可以按列显示它,它从数据库中获取的数据已转换为 json 格式。这是代码片段,请给我一些建议

<script type="text/javascript">
        webix.ajax("datacon.php", function(text, incomingData){
            //text = '{ some :"abc"}'
            var data=incomingData.json();



            webix.ui({
                container: "box",
                rows:[
                    {view:"template", type:"header", template: "some text"},
                    {view: "datatable", data: data, height: 300,
                        columns:[
                            {id:"date", header:"Date"},
                            {id:"ob", header:"OB"},
                            {id:"ore", header:"ORE"},
                            {id:"stratio", header:"Stripping Ratio"}
                        ]
                    }

                ]
            }); 

最佳答案

实际上您的代码无法正常工作。它显示片段中的错误,请检查。

此外,在上面的代码中,您必须提及 View 类型,例如“view : datatable/list/tree”或其中任何一个。进行更改并恢复。

在 webix DataTable 中,您无法添加单行。您必须根据其打印模式写入数据。

这是一个来自 webix 的数据表的简单示例

<script src="https://cdn.webix.com/edge/webix.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.webix.com/edge/webix.css">

<script>
var datatable = webix.ui({
    view:"datatable", 
    columns:[
        { id:"rank",    header:"",              width:50},
        { id:"title",   header:"Film title",    width:200},
        { id:"year",    header:"Released",      width:80},
        { id:"votes",   header:"Votes",         width:100}
    ],
    data: [
        { id:1, title:"The Shawshank Redemption", year:1994, votes:678790, rank:1},
        { id:2, title:"The Godfather", year:1972, votes:511495, rank:2}
    ]
});
</script>

您只需将您的“Id”与相应的数据标签相匹配即可。列部分中引用的 ID 应与数据文件的“Keys”相同。列的标题也是使用“header”参数设置的。

这些是一些有助于使用 webix 进行更快开发的工具。

  1. https://webix.com/skin-builder/?utm_source=newsletter&utm_medium=email&utm_campaign=3_free_tools_to_create_awesome_apps&utm_term=2017-09-26

  2. https://webix.com/form-builder/?utm_source=newsletter&utm_medium=email&utm_campaign=3_free_tools_to_create_awesome_apps&utm_term=2017-09-25

关于javascript - webix 数据表按列到行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46420472/

相关文章:

javascript - 过滤列的集合

javascript - 数据表寻呼机宽度

javascript - Webix(protoUI)中建议列表中的表单

javascript - 如何使用后端 Node JS 服务器的 sendmail 从 Webix 应用程序发送电子邮件

javascript - highchart donut - 通过从 userService 搜索,单击切片打开页面

javascript - 如何使用 python mechanize 解析动态更新的 .jsp 表单?

javascript - knockout js 使用 jquery 或 javascript 更改绑定(bind)

javascript - Angular - 更新过滤器上的 ngFor 索引

javascript - browser.elements(...).forEach 不是 webdriver.io 中的函数

javascript - 改变 richselect 的输入颜色