Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by dave on Nov 30, 2009 05:50
open dhtmlx forum
dhtmlxWindow

Hello again

I have a grid placed on tab window. then pressing on grid row i open a new window there i need all data from the selected row in form. once it closed and i select a new row,window is shown but,no form inside. as i understand after window closed i have to deactive event i use to open it and load data.

here 2 files

grid.php

<!-- Grid -->  
<style>
    div.gridbox div.ftr td{
        text-align:right;
        background-color:#E5F2F8;
        border-right:0px solid gray;
    }
    div.gridbox_light table.hdr td {
        text-align:center;
    }
</style>
   <div id="gridbox" style="width:100%;height:520px;overflow:hidden"></div>

  <script>//init grid and set its parameters (this part as always);

function windowUser() {
 var usrWin;
// w2;
 usrWin = new dhtmlXWindows();
    usrWin.enableAutoViewport(false);
    usrWin.attachViewportTo("a_tabbar");
    usrWin.setImagePath("libs/imgs/");
    w2 = usrWin.createWindow("w2", 40, 40, 920, 350);
    w2.setText("user_data");
 w2.attachObject('objForm',true);
 
}
        
    mygrid = new dhtmlXGridObject('gridbox');
    mygrid.setImagePath("libs/imgs/");
    mygrid.enableRowsHover(true); 
    mygrid.setHeader("קבוצה,שם פרטי,שם משפחה,ת.הצטרפות,img:[img/active.gif],img:[img/edit.gif],img:[img/sing.gif],img:[img/med.gif],img:[img/reg.gif],ספט,אוק,נוב,דצמ,ינו,פבר,מרץ,אפר,מאי,יונ,יול,אוג,הכנסה");
    mygrid.attachHeader("#select_filter,#text_filter,#text_filter,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;");
    mygrid.setInitWidths("155,105,105,75,*,*,*,*,30,30,30,30,30,30,30,30,30,30,30,30,30,45");
    mygrid.enableSmartRendering(true);
    mygrid.enableColumnAutoSize(true);
    mygrid.setColAlign("right,right,right,right,center,center,center,center,");
    mygrid.setColTypes("ed,ed,ed,co,ch,ch,ch,ch,price,price,price,price,price,price,price,price,price,price,price,price,price,price");
    //mygrid.attachFooter("Total quantity,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,<div id='reg'>0</div>,<div id='sep'>0</div>,<div id='oct'>0</div>,<div id='nov'>0</div>,<div id='dec'>0</div>,<div id='jan'>0</div>,<div id='feb'>0</div>,<div id='mar'>0</div>,<div id='apr'>0</div>,<div id='may'>0</div>,<div id='jun'>0</div>,<div id='jul'>0</div>,<div id='aug'>0</div>,<div id='all'>0</div>", ["text-align:left;"]);
    mygrid.setSkin("dhx_skyblue");
    var rowID=mygrid.getSelectedRowId();
    var detach=mygrid.attachEvent("onRowSelect", windowUser);
    
   // mygrid.detachEvent(usrWin);
   // mygrid.attachEvent("onEditCell", calculateFooterValues);
    //mygrid.attachFooter("#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#stat_total,#stat_total,#stat_total,#stat_total,#stat_total,#stat_total,#stat_total,#stat_total,#stat_total,#stat_total,#stat_total,#stat_total,#stat_total,#stat_total");
    mygrid.init();
   // mygrid.load("get.php", calculateFooterValues);
    mygrid.load("get.php");
    
</script>

<div id="objForm" style="width: 900px; height: 520px; overflow: auto;">
                <div style="font-family: Tahoma; font-size: 10px; height: 100%; overflow: auto; background-color: #FFFFFF;">
                <form action="" method="get" enctype="application/x-www-form-urlencoded" target="_self" dir="rtl" lang="he">
                    <table width="100%" style="margin-top: 10px;">
                        <tr>
                         <td width="100" align="right">Group:</td>
                            <td><select name="list_group" id="list_group">
        </select></td>
                            <td width="100" align="right">First Name:</td>
                            <td><input type="text"></td>
                            <td align="right">Last Name:</td>
                            <td><input type="text"></td>
                        </tr>
                        <tr>
                            <td align="right">Last Name:</td>
                            <td><input type="text"></td>
                        </tr>
                    </table>
                   </form>
                </div>
</div>
           
           

tabs.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><head>
<meta http-equiv="Content-Type" content="text/xml; charset=utf-8" />
<title>MAS</title>

</head>

<link rel="stylesheet" type="text/css" href="libs/dhtmlx.css">
<script src="libs/dhtmlx.js"></script>

<link rel="stylesheet" href="libs/scheduler/dhtmlxscheduler.css">
<script src="libs/scheduler/dhtmlxscheduler.js"></script>
<script src="libs/locale_he.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">

 function init() {
 
  scheduler.config.xml_date="%Y-%m-%d %H:%i";
  scheduler.config.multi_day = true;
 
  scheduler.init('scheduler_here',new Date(2009,7,11),"week");
  scheduler.load("libs/scheduler/events.xml");
 
 }
</script>

 

<body onload="init();">
<div id="a_tabbar" class="dhtmlxTabBar" oninit="doOnLoad();" imgpath="libs/imgs/" style="width:100%; height:570px;">


<div id="a1" name="יומן" width="100px">
<?php include("scheduler.php"); ?>  
</div>


<div id="a2" name="תשלומים" width="100px">
<?php include("grid.php"); ?>  


</div>

<div id="a3" name="פרטים אישיים"  width="100px">
<script>
var dhxLayout;
dhxTabbar;
dhxWins;
uGrid;
function doOnLoad() {
 dhxWins = new dhtmlXWindows();
    dhxWins.enableAutoViewport(false);
    dhxWins.attachViewportTo("a_tabbar");
    dhxWins.setImagePath("libs/imgs/");
    w1 = dhxWins.createWindow("w1", 40, 40, 920, 350);
    w1.setText("ימי הולדת");
    bgrid = w1.attachGrid();
 bgrid.enableRowsHover(true);
 bgrid.setHeader("קבוצה,שם פרטי,שם משפחה,ת.לידה,טלפון נייד,טלפון בבית,שם האם,טלפון אמא,שם האב,טלפון אב");
 //bgrid.attachHeader("#select_filter,#text_filter,#text_filter,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;");
 bgrid.setInitWidths("150,100,100,70,80,80,80,80,80,80,80");
 bgrid.enableSmartRendering(true);
 bgrid.setColAlign("right,right,right,right,right,right,right,right,right,right,");
 bgrid.setColTypes("ed,ed,ed,co,ed,ed,ed,ed,ed,ed");
    bgrid.setSkin("dhx_skyblue");
    bgrid.setImagePath("libs/imgs/");
 bgrid.init();
    bgrid.load("get_birth.php");
 
 dhxLayout = new dhtmlXLayoutObject("parentId", "5I");
    // access through cells;
    dhxLayout.cells("a").setText("פרטי התלמיד");
 dhxLayout.cells("a").attachObject("objA");
 dhxLayout.cells("b").setText("קבלות\חשבוניות");
 dhxLayout.cells("c").setText("מידע נוסף");
 dhxLayout.cells("d").setText("פרטי התקשרות");
 dhxLayout.cells("e").setText("מידע פיננסי");
    ugrid = dhxLayout.cells("e").attachGrid();
    ugrid.setImagePath("libs/imgs/");
    ugrid.setHeader("ת.הצטרפות,img:[img/active.gif],img:[img/edit.gif],img:[img/sing.gif],img:[img/med.gif],img:[img/reg.gif],ספט,אוק,נוב,דצמ,ינו,פבר,מרץ,אפר,מאי,יונ,יול,אוג,הערות");
    ugrid.attachHeader("&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;");
    ugrid.setInitWidths("80,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,*");
    ugrid.enableSmartRendering(true);
    ugrid.enableColumnAutoSize(true);
    ugrid.setColAlign("right,right,right,right,center,center,center,center,");
    ugrid.setColTypes("co,ch,ch,ch,ch,price,price,price,price,price,price,price,price,price,price,price,price,price,ed");

    ugrid.attachEvent("onGridLoaded",function(mygrid,rowId,main_index){
    this.setSelectedRow(rowId);
});
    ugrid.init();
       ugrid.load("get_user.php");


    // access through items;
    //dhxLayout.items[1].setText("Monkey Island 2: LeChuck's Revenge");
}

 

</script>
<div id="parentId" style="position: relative; top: 20px; left: 10px; width: 100%; height: 500px; aborder: #B5CDE4 1px solid;">
</div>
<div id="objA" style="text-align: center; padding-top: 10px;"><input type="button" value="undock" onclick="dhxLayout.cells('a').undock();">
<form action="" method="get" enctype="application/x-www-form-urlencoded" target="_self" dir="rtl" lang="he">

 

  <table width="100%" border="0" cellspacing="4" cellpadding="2">
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td><label>
        <input type="text" name="fname" id="fname">
      </label></td>
      <td>שם משפחה</td>
      <td><label>
        <input type="text" name="name" id="name">
      </label></td>
      <td>שם פרטי</td>
      <td><label>
        <select name="list_group" id="list_group">
        </select>
      </label></td>
      <td>קבוצה</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>

</div>

</div>

<div id="a4" name="ניהול נוכחות"  width="100px">
   
</div>
<div id="a5" name="הגדרות"  width="100px">
  
</div>
</div>

</body>
</html>

 

 

thanks

 

Answer posted by Alex (support) on Nov 30, 2009 07:23

Hello,

after the window closes, its content is removed. So, possibly it will be better to redefine close button behavior and hide the window (not to delete it) when the "close" button is pressed.  

var usrWin;

usrWin = new dhtmlXWindows();
usrWin.enableAutoViewport(false);
usrWin.attachViewportTo("a_tabbar");
usrWin.setImagePath("libs/imgs/");
w2 = usrWin.createWindow("w2", 40, 40, 920, 350);
w2.setText("user_data");
w2.attachObject('objForm',true);
w2.button("close").close = function() {
    w2.hide();
}
w2.hide();
 
function windowUser() {
    w2.show();
}

Answer posted on Nov 30, 2009 09:57
but each time its different data depends on selected row. is that will work? i need only selected data in the window form.
Answer posted by Alex (support) on Dec 01, 2009 03:12

You can change data inside form using document.getElementById(fieldId).value = someValue approach.

Answer posted by dave on Dec 01, 2009 06:03

hi

the script in your first answer is not work. once i put it in code grid data is empty

Answer posted by Alex (support) on Dec 01, 2009 06:21

Hello,

please provide the complete demo to recreate the issue (it can be also sent to support@dhtmlx.com)