EasyUI Forum
May 13, 2024, 06:47:24 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: How to create datagrid with new data on opening a window  (Read 5334 times)
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« on: November 28, 2016, 12:57:52 AM »

I have tried the following code to open a window using javascript:

Code:
<div id="expwin" class="easyui-window">
   <table id="expdg"></table>
</div>
Code:
$('#expwin').window({'onOpen',
      function(){
     var t = $('#expdg').datagrid({
      url:'get_expiring.php',      
      toolbar: '#exptoolbar',
      pagination:true,
        columns:[[
            {field:'drugname',title:'name',width:100},
            {field:'batchno',title:'batch',width:100},
            {field:'pack',title:'package',width:100},
            {field:'qps',title:'qpur',width:100},
            {field:'qs',title:'qsold',width:100},
            {field:'qout',title:'qout',width:100},
            {field:'entrydate',title:'endate',width:100},
            {field:'mdate',title:'mdate',width:100},
            {field:'expdate',title:'edate',width:100,align:'right'}
        ]]
    });
      return t;
}
});

To open the window:
Code:
<div class="t-list" onclick="$('#expwin').window('open')">test</div>
The problem is that there is no error in the console, and this does not populate the datagrid table as well. I want to populate the datagrid with data from get_expiring.php when I click test. How can I achieve this?
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: November 28, 2016, 02:22:17 AM »

Please call this code instead.
Code:
$(function(){
$('#expwin').window({
onOpen: function(){
$('#expdg').datagrid({
url: 'get_expiring.php',
//...
})
}
})
})
Logged
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« Reply #2 on: November 28, 2016, 09:05:15 AM »

Thanks very much, this 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!