jack
jack

Reputation: 73

easyui populate datagrid data based on combobox value

I'm using http://www.jeasyui.com.

I need to populate datagrid based on values from combobox.

I populate combobox with,

<input id="listcombo"class="easyui-combobox" name="lo_client_id" data-options="url:'get_lists.php',valueField:'id',textField:'listName',panelHeight:'auto'">

and it is working fine. Datagrid looks like,

<table id="dg" title="My Numbers" class="easyui-datagrid" style="width:500px;height:250px"

        url="get_users.php
        toolbar="#toolbar" pagination="true"
        rownumbers="true" fitColumns="true" singleSelect="true">
    <thead>
        <tr>
            <th field="number" width="50">Numbers</th>

        </tr>
    </thead>
</table> 

When I give url = "get_users.php?id=1 gives me required results, but id should be dynamic according to combobox. How can I do that ?

Upvotes: 1

Views: 6990

Answers (1)

bipen
bipen

Reputation: 36531

you can use the onSelect event of combobox and get the selected value and pass it to the url

HTML

 <input id="listcombo" name="listcombo">

$('#listcombo').combobox({
     url:'get_lists.php',
     valueField:'id',
     textField:'listName',
     panelHeight:'auto', 
     onSelect:function(record){
         $('#dg').datagrid({
            url:"get_users.php?id="+record.id 
         });
     }
}); 

Upvotes: 2

Related Questions