New Row in Grid and Database

Hi there,



now, i have a new problem.



I want to add a row by pressing enter or tab or click on the normal addRow- Button in my grid.



In this row i want to focus automaticly the second “ed” field, when the field is != ‘’ then it should add it in my database, read the new id out and add a new row.



If the user dont add any entrys in the “ed” then should it be ignored.



this is my source htm file:







and this is my source php file

<?php

    require_once("…/…/…/…/…/etc/mysql.php");

    $res=mysql_connect(DAB_HOST,DAB_USER,DAB_PASS);

    mysql_select_db(DAB_DBAS);



    require("…/…/…/…/…/opt/dhtmlx_connector/grid_connector.php");

    $grid = new GridConnector($res);

    #$grid->enable_log(“temp.log”,true);

    $grid->dynamic_loading(50);

    #$grid->render_table(“crm_data”,“id”,“id,company,street,zipcode,city,email,phone,fax”);

    $grid->render_sql(“SELECT * FROM user WHERE status=0 OR status=1”, “id”,“id,name,email,date,session,status,login_error,login_error_fatal”);

?>



I’ll hope you can help.



Sry, for my english.



Best regards

Florian Banowski

I want to add a row by pressing enter or tab or click on the normal addRow- Button in my grid.
You can use “onEnter” or “onTab” events to call addRow() method.
>>In this row i want to focus automaticly the second “ed” field
You can switch necessary cell to the edit mode using editCell() method.
Please check this article dhtmlx.com/docs/products/dhtmlxG … aprocessor


Hi, now i have written a function, which should add a row, and select the 2nd ed field automaticly. It runs good, but when i update my datagrid with clearAll and loadXML at the function onAfterUpdateFinish it only adds a row and dosent show the new content and it dosent select automaticly the 2nd field.



What can i do to comeoff?



Here’s the code-selection:



 function newRow()
 { 
  var id=mygrid.uid();
  mygrid.addRow(id,’’,0);
  mygrid.showRow(id);
  //(arguments[0]||window.event).cancelBubble=true;
  mygrid.selectCell(0,1,true,false,true);
 }



 function onEditCell (stage,rowId,cellInd,nValue,oValue)
 {
  if (stage==2&&cellInd==1&&nValue!=""){
   myDataProcessor.sendData();
  } 
 }



 function onAfterUpdateFinish (stage,rowId,cellInd,nValue,oValue)
 {
  mygrid.clearAll();
  mygrid.loadXML(“list.php?id={ID}”);
  //window.location.reload(true);
  newRow();
 }

Best regards
Florian Banowski

mygrid.loadXML(“list.php?id={ID}”); method works in asynchronous mode. newRow() function called event if not all rows was loaded to the grid. You should wait till all rows was loaded in the grid:
mygrid.loadXML(“list.php?id={ID}”,function(){
newRow();
});