我有一个来自easyui的组合框和网格,当组合框中当前所选项目发生变化时,我需要更改网格数据以显示详细数据。
以下是组合框的代码:
<input class="easyui-combobox" name="wg_id" id="wg_id" value="1"
data-options="
url:'pages/get_work_groups.php',
method:'get',
valueField:'work_group_id',
textField:'work_group',
panelHeight:'auto',
onSelect: function(rec){
$.post('pages/get_locations.php', {wg_id: '2'});
}
">
get_locations.php代码:
include '../conn.php';
$wg_id = 1;
if (isset($_REQUEST['wg_id'])) {
$wg_id = $_REQUEST['wg_id'];
}
$q = $conn->prepare("select * from locations where work_group_id = :wg_id");
$q->bindValue(':wg_id', $wg_id);
$q->execute();
$result = $q->fetchAll();
echo json_encode($result);
从get_locations.php返回的json数据是否正确,但我如何重新加载网格以显示这些数据呢?
答案 0 :(得分:1)
使用以下代码
<input class="easyui-combobox" name="wg_id" id="wg_id" value="1"
data-options="url:'pages/get_work_groups.php',
method:'get',
valueField:'work_group_id',
textField:'work_group',
panelHeight:'auto',
onSelect: function(rec){
$('#dg').datagrid({url:'pages/get_locations.php'});
}
">