Categories | Question details Back To List | ||
Updating with Data Processor and Grid I have the below code and a php data processor function. I have links on the page that call my 'delGridRow()' and 'addGridRow()' functions, and I have a problem with each one. The problem with deleting is that I can't seem to force the data processor to update the row. The grid puts a line through it, but it doesn't send to the server unless I set the update mode to 'cell'. With update mode set to either 'row' or manual, I have to move away from the row for it to save. When I call the delete function, I would like the grid to send the data to the server and update the grid. Regardless of the update mode, I can call mygrid.selectRow(someRowID) and it saves as well, but I would have to enumerate the rows to make sure that I choose one that exists. I'm sure this works, but I'm missing something. My problem with adding a row is that I want the grid to create the new row, go to a cell and begin editing. When I call mygrid.addRow() , the data processor saves it immediately, before I can enter the data, and it causes an error on the backend. Also, the mygrid.selectCell() function selects the row, but doesn't change the cell to edit mode. It may be the same issue since the row has already been saved by the data processor. Thanks, Tommy var mygrid; function doInitGrid() { mygrid = new dhtmlXGridObject("mygrid_div"); mygrid.setImagePath("' . $base_url . '/dhtmlx/imgs/"); mygrid.setHeader("Site,Oct1,Oct2,Oct3,Oct4,Type,Host,Desc"); mygrid.attachHeader("#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter"); mygrid.setColumnIds("site,ipo1,ipo2,ipo3,ipo4,type,host,dscr"); mygrid.setInitWidths("50,50,50,50,50,80,140,*"); mygrid.setColAlign("left,left,left,left,left,left,left,left"); mygrid.setSkin("light"); mygrid.setColSorting("str,int,int,int,int,str,str,str"); mygrid.setColTypes("ed,ed,ed,ed,ed,ed,ed,ed"); mygrid.enableEditTabOnly(1); mygrid.enableAutoHeigth(true,"250"); mygrid.enableSmartRendering(true); mygrid.preventIECaching(true); mygrid.init(); mygrid.loadXML("' . $base_url . '/r2apps/r2ipmgmt/gridload/"); var dp = new dataProcessor("' . $base_url . '/r2apps/r2ipmgmt/dp/"); dp.enableDataNames(true); dp.setUpdateMode("row"); dp.setTransactionMode("POST"); dp.init(mygrid); } function delGridRow() { if(mygrid.getSelectedRowId()) { if(confirm("Are you sure?")) { id = mygrid.getSelectedRowId(); mygrid.deleteSelectedRows(); //mygrid.selectRow(0); dp.setUpdated(id,true,true); dp.sendData(); } } else { alert("Please select a row first."); } } function addGridRow() { mygrid.addRow("newRowID","",0); mygrid.selectCell(0,2,true,false,true,true); } $(window).load(function () { doInitGrid(); }); Answer posted by Support on Aug 03, 2009 09:56 >>Also, the mygrid.selectCell() function selects the row, but doesn't change the cell to edit mode May be caused by the way, how command is called. If you are calling it from some link or button - onclick event which will be generated after your code processing will trigger logic of grid , which closes active editor on any click outside of grid To workaround the issue you can use <a onclick="setTimeout(addGridRow,1);" ... >>, before I can enter the data, and it causes an error on the You can disable auto-update mode before adding new row, or assign some validator to the grid ( which will validate empty values or other critical requirements and prevent sending of not-filled rows ) >>I can't seem to force the data processor to update the row mygrid.deleteSelectedRows(); The next command must send data to server side, without relation to current update mode mygrid.deleteSelectedRows(); dp.sendData(); If issue still occurs, even with such code - please provide info about used version of dataprocessor. |