引导表树网格不起作用

时间:2018-10-31 17:16:00

标签: jquery bootstrap-table

我正在使用bootstrap-table创建一个表,并在其中包含一个treegrid,如示例所示。但是我就是无法正常工作。我根据示例构建了代码,并回答了here

这是我的代码。

HTML:

<div class="table-responsive table-custom">
    <table id="tableData" class="table table-hover table-sm"></table>
</div>

javascript:

success: function (result) {
    // I have got three fields which need to be put as columns. And I want Request ID to contain the grid element.
    var html = '<thead><tr><th data-field="RequestID">Request ID</th><th data-field="Date">Date</th><th data-field="Message">Message</th></tr></thead>'
    var requestID = null;

    for (var i = 0; i < result.length; i++) {
        if (requestID != result[i].RequestID) {
            requestID = result[i].RequestID;
            result[i].ParentID = 0;
            result[i].RequestID = result[i].RequestID;
            result[i].Message = result[i].Message;
        }
        else {
            requestID = result[i].HelpRequestID;
            result[i].ParentID = result[i].RequestID;
            result[i].RequestID = result[i].RequestID;
            result[i].Message = result[i].Message;
        }
    }
    $("#tableData")[0].innerHTML = html;

    //bootstrap table code here
    $table.bootstrapTable({
        data: result,
        striped: true,
        height: $(window).height(),
        idField: 'HelpRequestID',
        treeShowField: 'HelpRequestID',
       parentIdField: 'ParentID',
    });
}

0 个答案:

没有答案