EasyUI Forum
May 16, 2024, 08:42:16 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: Datagrid inside an AJAX window  (Read 9069 times)
alozano
Newbie
*
Posts: 3


View Profile Email
« on: June 15, 2015, 01:50:29 AM »

Hello,

    I'm trying to open an AJAX windows that have a datagrid that loads data from a URL.
    In the window's openning it launch the exception: Uncaught TypeError: Cannot read property 'panel' of undefined jquery.easyui.min.js:9805
    On the child window I put a button that reload datagrid URL data and it works correctly when I click it.
    But I need to auto load the data when the user opens the child window.

Thanks in advance,

Code of the main window(main.html):

Code:
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" type="text/css" href="js/themes/default/easyui.css" />
        <script type="text/javascript" src="js/jquery.min.js"></script>
        <script type="text/javascript" src="js/jquery.easyui.min.js"></script>
    </head>
<body>
    <a href="#" class="easyui-linkbutton" onclick="OpenChildWindow();">Open child window</a>
    <div id="wchild" class="easyui-window" title="Child window" closed="true" collapsible="false">
    </div>
    <script type="text/javascript">

        function OpenChildWindow() {

            $('#wchild').panel('resize', { height: $(window).height() * 0.9 });
            $('#wchild').panel('resize', { width: $(window).width() * 0.9 });
            $('#wchild').window('refresh', 'child.html').window('center').window('open');
           
        };

    </script>
</body>
</html>


Child window code(child.html):

Code:
<a href="#" class="easyui-linkbutton" onclick="ReloadData();">Reload data</a>
<table id="grddata" class="easyui-datagrid"
       idfield="IdField"
       url="handler.ashx?mode=test">
    <thead>
        <tr>
            <th data-options="field:'IdField',align:'left'">IdField</th>
            <th data-options="field:'Field1',align:'left'">Field1</th>
            <th data-options="field:'Field2',align:'left'">Field2</th>
            <th data-options="field:'Field3',align:'left'">Field3</th>
        </tr>
    </thead>
</table>
<script>
    function ReloadData() {
        $('#grddata').datagrid({ url: 'handler.ashx?mode=test' });
    }
</script>



Sample data returned from handler.ashx:

"[{"IdField":36,"Field1":"2015-06-15T10:47:34","Field2":"Puig","Field3":"Joan"},{"IdField":40,"Field1":"2015-06-15T10:47:34","Field2":"Costa","Field3":"Maria"},{"IdField":41,"Field1":"2015-06-15T10:47:34","Field2":"Pozo","Field3":"Julia"}]"
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: June 15, 2015, 08:32:11 AM »

Please rewrite your 'OpenChildWindow' function as:
 
Code:
function OpenChildWindow() {
    $('#wchild').window('resize', {
        width: $(window).width()*0.9,
        height: $(window).height()*0.9
    }).window('open').window('center').window('refresh','child.html');
};
Logged
alozano
Newbie
*
Posts: 3


View Profile Email
« Reply #2 on: June 16, 2015, 01:52:17 AM »

Thank you jarry for your response, but it says the same error.

Then I try to simplify the OpenChildWindow function to this code below and I got the same error.

Code:
        
function OpenChildWindow() {

            $('#wchild').window('refresh', 'child.html').window('open');

        };

Any ideas?
Thank's,

Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #3 on: June 16, 2015, 04:43:39 AM »

Please try the code below instead.
Code:
$('#wchild').window('open').window('refresh', 'child.html');
Logged
alozano
Newbie
*
Posts: 3


View Profile Email
« Reply #4 on: June 16, 2015, 06:13:27 AM »

Thank you jarry now it works like a charm!!!   Smiley
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!