EasyUI Forum

General Category => General Discussion => Topic started by: john17 on July 20, 2014, 06:22:46 PM



Title: pass id from datagrid to datagrid under dialog box
Post by: john17 on July 20, 2014, 06:22:46 PM
hi guys,

how can i pass the id of the select row in datagrid to another datagrid under/inside the edit dialog box?
here is my reference : http://www.jeasyui.com/tutorial/app/crud.php

thanks ;D ;D ;D


Title: Re: pass id from datagrid to datagrid under dialog box
Post by: stworthy on July 21, 2014, 12:02:39 AM
Call 'getSelected' method of datagrid to get the selected row data. You can call 'reload' method to reload another datagrid by passing the selected id value of the first datagrid. Please refer to the code below:
Code:
var row = $('#dg1').datagrid('getSelected');
if (row){
  var id = row.id;  // get the row id
  $('#dg2').datagrid('reload', {id:id});
  // ...
}


Title: Re: pass id from datagrid to datagrid under dialog box
Post by: john17 on July 21, 2014, 12:14:40 AM
thank you very much stworthy for your reply very much appreciated I will try the code and comeback for the outcome


Title: Re: pass id from datagrid to datagrid under dialog box
Post by: john17 on July 21, 2014, 01:33:01 AM
hi guys,

for the sake of others here's what I've done

Code:
<table id="dg2" class="easyui-datagrid" style="width:auto;max-width:1300px;height:auto" rownumbers="true" fitColumns="true" singleSelect="true" autoRowHeight="false">
                        <thead>
                            <tr>
                                <th field="company_clinic_name" width="30" sortable="true">Clinic Name</th>
                                <th field="Municipality" width="50" sortable="true">Municipality</th>
                                <th field="Province" width="50" sortable="true">Province</th>
                            </tr>
                        </thead>
                    </table>

Code:
var row = $('#dg').datagrid('getSelected');
            if (row){
                
                $('#dg2').datagrid({
                    url:'get-clinic.html?clinid='+row.system_md_id
                });
}

Quote
noted! this data grid is inside a edit dialog box my reference is in my first comment

Quote
Thank you stworthy!!