Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by john on Sep 21, 2008 23:59
open dhtmlx forum
the question about change input box display and export to excel

First, when we on click some cell , the cell will become input box . Is it possible to make editable cells look like input box before I click the cell?????


second, I want to ask sth about exporting grid into excel. I hv read some example in KB.

http://dhtmlx.com/docs/products/kb/index.shtml?cat=search&page=1&q=1400&ssr=yes

it is right for me to call function toExcel() by mygrid.loadXML("get3.xml",toExcel ),
if it works , what is the sytax of mygrid.loadXML when it need to call two or functions?? i.e.mygrid.loadXML("get3.xml",functionA, toExcel )????? THANK A LOT



function toExcel(){
var jrow = mygrid.getRowsNum();
var jstr = mygrid.getAllItemIds();
jrows = new Array();
jrows = jstr.split(',')
var jcol = mygrid.getColumnCount();
var xls = new ActiveXObject("Excel.Application")
xls.visible = true
xls.Workbooks.Add
/*****************************************/
var row =0;
for (i = -1; i<jrows.length; i++){
row++
col =0;
for (j=0; j<jcol; j++){
col++
if (i<0){
xls.Cells( row, col).Value = mygrid.getHeaderCol(j);
}
else{
xls.Cells( row, col).Value = mygrid.cells(jrows[i],j).getValue();
}
}
}
var rng = xls.Columns(String.fromCharCode(65, 58, 65 + jcol))
rng.AutoFit
//if (isave=1) {xls.ActiveWorkbook.Save ()}
// xls.ActiveWorkbook.Close ()
}


Answer posted on Sep 22, 2008 02:58
No, there is no possibility to keep cells in opened state all the time, but you can start cells editing on single click using the following method:

enableEditEvents(click, dblclick, f2Key)
enable/disable events which fire excell editing, mutual exclusive with enableLightMouseNavigation
Object: dhtmlXGridObject

File required:dhtmlxgrid.js
  • click - true/false - enable/disable editing by single click
  • dblclick - true/false - enable/disable editing by double click
  • f2Key - enable/disable editing by pressing F2 key

  • To call more then one function when xml loading was finished you can call them within another function like this:

    mygrid.loadXML("some.xml", function(){

    function1();
    function2();
    ...
    functionN();

    })