JSONP を介して Fusion Tables から jqGrid に取得しているデータの一部 (3 つの住所列を 1 列に) をマージしたいと考えています。
これが可能かどうか/どうすればよいか誰にもわかりますか? 残念ながら、Fusion Tables SQL API は現在、SELECT コマンドによる CONCAT をサポートしていません。
Oleg は、長いデータがある場合に基本的に 2 つの列を colspan-ing するためのコードを提供しましたが、実際には複数の列からデータを取得し、jqGridで1 つの列として表示したいと考えています。
前もって感謝します
編集、コードのスニペットを追加:
datatype: "jsonp", // "json" or "jsonp"
colNames: ["id","lat","long","Name","Address","","","Postcode"],
colModel:[
{name:'id',index:'id',key:true,sorttype:'int',hidden:true,sortable:true},
{name:'latitude',index:'latitude',hidden:true},
{name:'longitude',index:'longitude',hidden:true},
{name:'name',index:'name',width:170,sortable:false,sorttype:'text'},
{name:'address_line_1',index:'address_line_1',width:400,formatter:function (cellvalue, options, rowObject) {
addPart1 = rowObject[4];
addPart2 = rowObject[5];
addPart3 = rowObject[6];
fullAddress = addPart1 + addPart2 + addPart3;
return fullAddress;},sortable:false,sorttype:'text'},
{name:'address_line_2',index:'address_line_2',sortable:false,sorttype:'text',hidden:true},
{name:'address_line_3',index:'address_line_3',sortable:false,sorttype:'text',hidden:true},
{name:'postcode',label:'postcode',width:80,sortable:false,sorttype:'text'}
],
jsonReader: {
cell: "", // the same as cell: function (obj) { return obj; }
root: "table.rows",
page: function (obj) { return 1; },
total: function (obj) { return 1; },
records: function (obj) { return obj.table.rows.length; }
},
.gov テーブルからの一般的な公開データの例を次に示します (私のテーブルは基本的に同じ設定です)。後で質問を整理して、人々が質問/回答を簡単に見られるようにします:)
<script type="text/javascript">
var queryText = "SELECT * FROM 185189";
jQuery(document).ready(function() {
jQuery("#rTable").jqGrid({
url: 'http://www.google.com/fusiontables/api/query?sql=' +
encodeURI(queryText) + '&jsonCallback=?',
postData: "",
datatype: "jsonp",
colNames: ["col1","col2","col3","col4"],
colModel:[
{name:'FACID',index:'FACID',key:true,sorttype:'int',sortable:true},
{name:'FACNAME',index:'FACNAME'},
{name:'FAC_ADDRESS1',index:'FAC_ADDRESS1',sortable:false,sorttype:'text'},
{name:'FAC_ADDRESS2',index:'FAC_ADDRESS2',sortable:false,sorttype:'text'}
],
jsonReader: {
cell: "",
root: "table.rows",
page: function (obj) { return 1; },
total: function (obj) { return 1; },
records: function (obj) { return obj.table.rows.length; }
},
rowNum:10,
rowList:[10,20,30],
pager: '#pager2',
sortname: 'name',
sortorder: "asc",
viewrecords: true,
loadonce: true,
height: "100%",
multiselect: true,
caption: ""
}); // END CREATE GRID
jQuery("#rTable").jqGrid('navGrid','#pager2',{edit:false,add:false,del:false}); // paging options
});
</script>