EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: wel on January 06, 2016, 05:28:21 AM



Title: Reload grid data based on combo box selection
Post by: wel on January 06, 2016, 05:28:21 AM
I have a combo box and grid and I need to make the grid data change to display detail data when the current selected item in the combo box change.

Here is the code of the combo box:

Code:
<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){
         

        }

">

The PHP file that I get json data from:

Code:
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);

What is the code I should use in the onSelect event to reload grid data ?


Title: Re: Reload grid data based on combo box selection
Post by: aswzen on January 06, 2016, 06:12:57 AM
<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){
           $('#YOUR_TABLE_ID').datagrid({
            url: 'NEW URL'
            });
        }

">


Title: Re: Reload grid data based on combo box selection
Post by: wel on January 06, 2016, 07:09:06 AM
many thanks aswzen it work

I used the url like this get_locations.php?wg_id=2 to pass a variable value to php file but just for learning can I pass the value as "post" instead of "get" to do that same thing ?


Title: Re: Reload grid data based on combo box selection
Post by: arma on January 08, 2016, 03:40:29 AM
many thanks aswzen it work

I used the url like this get_locations.php?wg_id=2 to pass a variable value to php file but just for learning can I pass the value as "post" instead of "get" to do that same thing ?

You can use data grid reload method with post parameter.


Title: Re: Reload grid data based on combo box selection
Post by: wel on January 08, 2016, 06:10:05 AM
ok thanks arma