EasyUI Forum
May 01, 2024, 01:30:01 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Details in a new Winndow  (Read 7557 times)
Marco
Newbie
*
Posts: 12


View Profile Email
« on: November 11, 2014, 11:46:01 AM »

Hi !
J'm new to the Forum and j'm new to jqEasyUI.
J 'd like to Know if is possibile to show details in a data grid with  a new window.

J have the form Orders and when j click the button details
the new window should display the data grid with the related details but
j only see the data grid with no records, maybe there must be something wrong with the PHP file it seems
not to get the VAR $id.

Thanks for your help.

<!-- Section html datagrid Orders    -->
      
   <table id="tt" class="easyui-datagrid" style="width:700px;height:450px"
         url="Order_get_search.php"
         title="Ordini fornitori" iconCls="icon-search" toolbar="#tb"
         rownumbers="true" pagination="true" singleSelect="true" fitColumns="true">
    <thead>
         <tr>
            <th field="Numero" width="120">Numero</th>
            <th field="Riferimento" width="300">Riferimento</th>
            <th field="Data" width="300">Data</th>
            <th field="id" width="300">ID</th>
         </tr>
      </thead>
   </table>
   
<!-- End section -->

<!-- Section html datagrid Orders details    -->   

 <table id="tt_dt"class="easyui-datagrid" title="Dettagli" style="width:700px;height:250px"
            data-options="singleSelect:true,collapsible:true,url:'Order_get_details.php',method:'post'">
        <thead>
            <tr>
                <th data-options="field:'ID_O',width:80">ID_O</th>
                <th data-options="field:'Codice',width:100">Codice</th>
                <th data-options="field:'Descrizione',width:80,align:'right'">Descrizione</th>
                <th data-options="field:'Quantita',width:80,align:'right'">Quantità</th>
            </tr>
        </thead>
    </table>




var url;
 // function open orders details

function openDett()
{
var row = $('#tt').datagrid('getSelected');
if (row){
$('#win').window('open')
url = 'Order_get_details.php?id='+row.id;
}
}


PHP Order_get_details.php
<?php

$id = intval($_REQUEST['id']);

include 'conn.php';

$sql = " select * from Dett_Ordini_Forn where id_o =$id";
$rs = mysql_query ($sql);

$result = array();
while($row = mysql_fetch_object($rs)){
    array_push($result, $row);
}
      
     
echo json_encode($result);

?>
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: November 11, 2014, 07:10:07 PM »

To open a window with the detail datagrid inside it, please move the datagrid component into the window component. In order to load data for datagrid, just call 'load' method with some request parameter values.
Code:
<div id="win" class="easyui-window" style="width:800px;height:400px">
<table id="tt_dt"class="easyui-datagrid" title="Dettagli" style="width:700px;height:250px"
            data-options="singleSelect:true,collapsible:true,url:'Order_get_details.php',method:'post'">
        <thead>
            <tr>
                <th data-options="field:'ID_O',width:80">ID_O</th>
                <th data-options="field:'Codice',width:100">Codice</th>
                <th data-options="field:'Descrizione',width:80,align:'right'">Descrizione</th>
                <th data-options="field:'Quantita',width:80,align:'right'">Quantità</th>
            </tr>
        </thead>
    </table>
</div>
<script>
function openDett()
{
var row = $('#tt').datagrid('getSelected');
if (row){
$('#win').window('open');
$('#tt_dt').datagrid('load',{id:row.id});
}
}
</script>
Logged
Marco
Newbie
*
Posts: 12


View Profile Email
« Reply #2 on: November 12, 2014, 02:53:20 AM »


Ok, many thanks

Now it works
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!