EasyUI Forum
May 16, 2024, 07:51:36 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Reload grid data based on combo box selection  (Read 9558 times)
wel
Newbie
*
Posts: 30


View Profile Email
« 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 ?
Logged
aswzen
Sr. Member
****
Posts: 287


Indonesian

aswzen
View Profile WWW Email
« Reply #1 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'
            });
        }

">
Logged

Regards,
Sigit

- Indonesian jEasyUI Facebook page : https://www.facebook.com/groups/jeasyuiid/
wel
Newbie
*
Posts: 30


View Profile Email
« Reply #2 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 ?
« Last Edit: January 06, 2016, 07:10:53 AM by wel » Logged
arma
Full Member
***
Posts: 110


View Profile
« Reply #3 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.
Logged
wel
Newbie
*
Posts: 30


View Profile Email
« Reply #4 on: January 08, 2016, 06:10:05 AM »

ok thanks arma
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!