如何根据组合框选择重新加载网格数据?

How to reload grid data based on combo box selection?

我有一个来自 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 数据是正确的,但我如何才能使网格重新加载以显示这些数据?

使用下面的代码,

 <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'});
            }
    ">