【发布时间】:2015-04-30 21:33:06
【问题描述】:
我对修复以下代码感到非常沮丧。我是 Javascript 新手,在这里我需要一点帮助:
我有以下代码,我试图在 Bootstrap-Table 中插入所有这些但没有成功。我总是收到下一个错误:
没有找到匹配的记录。
<script>
function showResult(sectoresURL) {
$('#info').empty(); // First, remove all child in stack.
$.getJSON(sectoresURL, function (json) {
if (sectores.getVisible() && typeof(json.features[0]) != 'undefined') {
$('#info').append('<table id=table-javascript></table>');
buildSectorTable(sectoresURL);
}
});
}
function buildSectorTable(sectoresURL) {
$('#table-javascript').bootstrapTable({
method: 'get',
url: sectoresURL,
cache: true,
height: 400,
striped: true,
pagination: true,
pageSize: 50,
pageList: [10, 25, 50, 100, 200],
search: true,
showRefresh: true,
minimumCountColumns: 2,
clickToSelect: false,
showToggle: true,
columns: [{
field: 'type',
title: 'Numero',
align: 'center',
valign: 'bottom',
sortable: true
}]
});
}
</script>
在这里,我只是尝试插入“Numero”。
顺便说一下,JSON 数据是:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": "SectoresComunaCurico.34",
"geometry_name": "FiguraGeometrica",
"properties": {
"Numero": 19,
"Sector": "Cordillera"
}
}
],
"crs": {
"type": "name",
"properties": {
"name": "urn:ogc:def:crs:EPSG::32319"
}
}
}
【问题讨论】:
-
示例数据是整个数据集,还是列表中的单个项目?
-
请展示您尝试过的内容,以便我们尝试更新,而不是期望这里有人为您从头开始编写。还显示预期输出
-
您的问题可能是列表不在数据的顶层。我的意思是
[{"key":"value",...},{"key":"value2",...}]而不是{"key":[{"key":"value",...},{"key":"value2",...}]}
标签: javascript jquery html json twitter-bootstrap