ShieldUI v 1.7.36 NP
URL:http://hccm.org/gala_signup_list.php
代码
HTML:
<div class="about-bottom">
<div class="col-md-12 about-left">
<div id="grid"></div>
</div>
</div>
Javascript:
$(document).ready(function() {
$('#return_btn').click(function() {
window.location = 'gala.php';
})
plgrid = $("#grid").shieldGrid({
dataSource: {
remote: {
read: {
url: "api/GetGalaSignupList",
dataType: "json",
xhrFields: {
withCredentials: false
}
}
},
noRecordsText: "There are no Registrants",
columns: [
{field:'registrant_name', title: "Registrant Name", width: "30%"},
{field: 'registrant_email', title: "Email", width: "30%"},
{field: 'registrant_phone', title: "Phone"},
{field: 'registrant_mail', title: "Address", width: "30%"},
{field: 'table_name', title: "Table Name", width: "20%"},
{field: 'numtix', title: "Num Tix", width: "20%"}
]
}
});
plgrid.show();
});
数据,可以在URL上看到<snip>
数据
[
{
"registrant_name":"Jeff Seiler",
"registrant_email":"<snip>",
"registrant_phone":"<snip>",
"registrant_mail":"507 Las Colinas",
"ticket_type":"Individual",
"table_name":"Mr and Mrs Jeff Seiler",
"numtix":"2"
},
{
"registrant_name":"Jan Halstead",
"registrant_email":"<snip>",
"registrant_phone":"<snip>",
"registrant_mail":"115 Mason Oaks",
"ticket_type":"Individual",
"table_name":"",
"numtix":"1"
}
]
但是它没有显示基于title属性的标题,它仅显示JSON列名称。我做错了什么导致这个?我可以更改JSON,但想知道为什么title属性不起作用。
答案 0 :(得分:1)
我看到您正在从url远程读取数据,我认为您应该定义一个 数据源中使用的字段的模式。您可以在这里查看它们的状态 定义。您应该指出路径和数据类型。
https://www.shieldui.com/documentation/datasource/javascript/api/settings/schema/fields
我怀疑未显示标题的原因是您尚未定义字段架构。