首页 > 解决方案 > 使用 javascript 和 crm 数据在 html 中创建表

问题描述

在我的 javascript 文件中,我正在尝试使用 html 创建一个表。

我有一个实体的记录列表,其中包含合同 ID、姓名、地址等字段。

var filter = "?$select=*&$filter=_plus_franchisee_value eq " + serviceProviderID;
PlusCRM.RetrieveMultiple("plus_franchiseecontracts", filter, function (records) {
        $("#tblNewAssignments").find("tbody").empty();
        console.log("vendorcontracts list....................");
        console.log(records);
        });

在表格的第一列中,我想显示应该显示所有合同 ID 的下拉列表。选择 id 后,第 2 列和第 3 列应填充其各自的名称和地址。填满后,应出现第二行,下拉菜单应再次显示帐户列表。

html:

<body onfocusout="parent.setEmailRange();" style="overflow-wrap: break-word;">
    <div class="row">
        <div class="col-md-12">
            <h5>New Assignments</h5>
            <hr>
            <div id="divNewAssignments">
                <table id="tblNewAssignments">
                    <thead>
                        <tr>
                            <th>Vendor Contract</th> (this should be drop down)
                            <th>Volume Purchased</th>
                            <th>% Fulfilled</th> 
                            <th>Volume Owed</th> 
                            <th>Vendor Amount</th> 

                        </tr>
                    </thead>
                    <tbody></tbody>
                    <tfoot></tfoot>
                </table>
                <div class="inline-loader"></div>
                <div class="no-records" style="display: none">No records found</div>
            </div>
        </div>  
    </div>
</body></html>

请帮助我实现这一目标。

谢谢

标签: javascripthtmldrop-down-menucrm

解决方案


这可能对你有帮助,我不确定。 使用 html 在表格中添加下拉列表

如果你想用 javascript 做同样的事情,你可以这样做。

function func(){
var addrow = '<tr>'
addrow += <td>'
addrow += '<select>        
            <option value="">record1</option>
            <option value="">record2</option>
            <option value="">record3</option>
            <option value="">record4</option>
    </select>'
addrow += '</td>'
addrow += '</tr>'

for(var i = 0; i < length_of_records; i++){
   jQuery("#tblNewAssignments tbody").append(addrow);
   }
}

推荐阅读