将音频控件添加为自定义字段 - JSGrid

时间:2017-08-31 20:52:56

标签: javascript jsgrid

我是JS的新手,并且一直在为我的所有网格使用JSGrid。我正处于需要添加自定义字段的位置。问题是,我不确定是否可以将HTML添加为数据的一部分。我要做的是添加一个音频控件来播放每个特定行的MP3。我能够在那里获得灰色控制,但无法获取文件。这里的任何帮助将不胜感激!这是示例代码:

<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.5.3/jsgrid.min.css" />
<link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.5.3/jsgrid-theme.min.css" />
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jsgrid/1.5.3/jsgrid.min.js"></script>
<body>



<div id="jsGrid">
<script>

    var AudioField = function(config) {
    jsGrid.Field.call(this, config);
};

AudioField.prototype = new jsGrid.Field({

 itemTemplate: function(value) {
        return $("<audio controls>").css({
            display: "inline-block",
            width: "50px",
            height: "22px"
        });
    },



});

jsGrid.fields.audio = AudioField;


    var clients = [
        { "ID": 0, "User": "Bob Jones", "Instrument": "Banjo", "Notes": "",  "Listen": false, "Audio": "<audio controls><source src = 'directory/0.mp3' type = 'audio/mp3'></audio>"},
        { "ID": 1, "User": "Lindsay Wilson", "Instrument": "Banjo", "Notes": "", "Listen": false, "Audio": "" }
    ];



    $("#jsGrid").jsGrid({
        width: "100%",
        height: "400px",

        inserting: false,
        editing: true,
        sorting: true,
        paging: true,

        data: clients,

        fields: [
            { name: "ID", type: "number", width: 50, validate: "required" , editing: false},
            { name: "User", type: "text", width: 200, editing: false },
            { name: "Instrument", type: "text", width: 200, editing: false },
            { name: "Notes", type: "text", width: 400},
            { name: "Listen", type: "checkbox", title: "Listen", sorting: false , editing: true},
            { name: "Audio", type: "audio"},
            { type: "control" }
        ]
    });
    items = $("#jsGrid").jsGrid("option", "data");
    console.log(items)
</script>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

一位朋友帮我解决了这个问题。问题是CSS问题,而不是JavaScript。如果我删除以下代码,它可以正常工作。

helper_bbox.geometry.boundingSphere