Categories | Question details Back To List | ||
problem of combo and grid Dear knowledge base team: I have an Enterprise dhtmlxTreeGrid (dhtmlxTreeGrid_v13_Pro_70414). I'm facing some problem with integrating combo in grid. (Please see my program below). I have a combo in the first column of the grid. I want to copy the selected row and paste it below when I click the href "copyrow". But there is no options in the new row. Could you please give me some suggestions to achieve this function? Thanky very much. I'm looking forward to your reply. Best regards L.H. html--------------------------------------------------------------------------------------------------------------------- ... <div><a href='#' onclick="copyrows()">copyrow</a></div> ... <script> mygrid = new dhtmlXGridObject('gridbox'); mygrid.imgURL = "../imgs/"; mygrid.setHeader("Combo,Mode"); mygrid.setInitWidths("150,300") mygrid.setColTypes("combo,ro"); mygrid.init(); mygrid.loadXML("gridCombo.xml"); function copyrows(){ var rowId=mygrid.getSelectedId() mygrid.addRow(rowId+"n","",mygrid.getRowIndex(rowId)+1); //adding new row for (var i=0; i<mygrid.getColumnCount(); i++){ // set types for each column in newly added row var type=mygrid.cells2(0,i).cell._cellType; // here 0 - index of row , from which types will be copied mygrid.setCellExcellType(rowId+"n",i,type); } mygrid.copyRowContent(rowId, rowId+"n") } </script> ... xml------------------------------------------------------------------------------------------------------------------------------------------ <?xml version="1.0" encoding="UTF-8" ?> - <rows> - <row id="1"> - <cell xmlcontent="0"> <value>one</value> <url>data.xml</url> </cell> <cell>loading from special xml</cell> </row> - <row id="2" selected="1"> - <cell xmlcontent="2"> - <complete> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> <option value="4">four</option> <option value="5">five</option> <option value="6">six</option> <option value="7">seven</option> <option value="8">eight</option> <option value="9">nine</option> <option value="10">ten</option> </complete> </cell> <cell>loading from grid xml</cell> </row> </rows> Answer posted by Alex (support) on Jun 19, 2009 03:47 Hello, copyRowContent method doesn't copy the additional data (combo options in this case). And moreover the combo excell in the grid 1.3 is not so flexible as in the latest grid (it doesn't allow to initialize combo from JS, the data can be loaded only from grid xml). So, we recommend you to update grid to the latest one. If it isn't possible, you can try to use the following approach: function copy(id,new_id){ The server_script should return xml that contains the data from copying row but "id" attribute should be equal to new_id. For example if you want to copy 2 and paste to row1. The server-side script should return the following xml: <?xml version="1.0" encoding="UTF-8" ?> |