Combogrid 下拉框無數據,通常是 columns 配置與返回 JSON 字段不匹配,或 url 路徑錯誤。
<input id="cg" style="width:250px">
$('#cg').combogrid({
panelWidth: 500,
idField: 'itemid',
textField: 'productname',
url: '/api/products', // 返回 JSON: {total: 10, rows: [...]}
columns: [[
{field: 'itemid', title: 'ID', width: 80},
{field: 'productname', title: '產品名', width: 120},
{field: 'price', title: '價格', width: 80, align: 'right'}
]],
fitColumns: true
});
{
"total": 2,
"rows": [
{"itemid": "1", "productname": "筆記本", "price": 5999},
{"itemid": "2", "productname": "鼠標", "price": 199}
]
}
data: [...] 替代 url,適合靜態字典。columns 可定義多行表頭、凍結列、formatter 渲染。navigation: true 支持上下鍵選擇。onChange 重新載入另一 Combogrid 的 url。total/rows。idField/textField 是否存在於 rows 對象中。