Categories | Question details Back To List | ||
[=sum] problems on some columns Dear Sir/Madam, I have a treegrid. One of the fields is a budget field with the type int. If a row has children, this budget field has a sum of his children. All this works fine. The problem starts when I am dragging and dropping. When I drop a row(let's call this r1) on another row(r2), I check if r2 had children before the row dropped. If r2 is a new parent his type should change into [=sum]. In theory everything works fine, but on occasions the budget field of r2 will become; [=sum], although it follows exactly the same path in the debugger.. How can I fix this? Thanks in advance, Dennis Pullens ============CODE=========== function drop_f(r1,r2){ //if the row is dragged on the same level as the top level row, it should cancel. if(r2 == null || r2 == 'undefined'){ var projectNr = Request("ProjectNr"); alert('De pagina wordt herladen, sorry voor het ongemak.'); document.location='?ProjectNr='+projectNr; return false; } //the top level row may not be dragged if(r1 == 1 || r1 == null){ alert('Je mag het project niet verslepen'); return false; } else{ //update the database without refreshing the page using an ajax-sack ajax.requestFile = "updateDetailplanning.aspx?action=drop&ProjectNr="+Request("ProjectNr")+"&r1="+r1+"&r2="+r2; ajax.method = "POST"; ajax.onCompletion = nothing; ajax.runAJAX(); //give the new parent a color and disable the budgetfield mygrid.setRowColor(r2,"#C6E2FF"); mygrid.cells(r2,budgetIndex).setDisabled(true); //if the parent wasn't a parent before var childArr = mygrid.getSubItems(r2).split(","); if(childArr.length < 2){ //mygrid.cells(r2,budgetIndex).setValue(null); mygrid.cells(r2,budgetIndex).setValue("sum"); } //if the dropped row has childs, the rowcolors and types change, this will set them right again if(mygrid.hasChildren(r1)){ mygrid.setRowColor(r1,"#C6E2FF"); //mygrid.cells(r1,budgetIndex).setValue("=sum"); childArr = mygrid.getAllSubItems(r1).split(","); var i; for(i = 0; i < childArr.length; i++) { if(mygrid.hasChildren(childArr[i])){ //mygrid.cells(childArr[i],budgetIndex).setValue("=sum"); mygrid.setRowColor(childArr[i],"#C6E2FF"); } else{ mygrid.setCellExcellType(childArr[i],budgetIndex,"ed"); } } } //if the dropped row doesn't have childs, the row should be editable. else{ mygrid.setCellExcellType(r1,budgetIndex,"ed"); mygrid.cells(r1,budgetIndex).setDisabled(false); } //if the parent of the dropped row has no childs after the drop, make it editable and white if(parentIdDrop != null){ if(!mygrid.hasChildren(parentIdDrop)){ mygrid.setRowColor(parentIdDrop,"#FFFFFF"); mygrid.cells(parentIdDrop,budgetIndex).setValue('0'); mygrid.setCellExcellType(parentIdDrop,budgetIndex,"ed"); mygrid.cells(parentIdDrop,budgetIndex).setDisabled(false); } else{ } } //check the icons on the first row checkBudgets(mygrid.getParentId(r1)); checkBudgets(parentIdDrop); //expand the new parent of the dropped row mygrid.openItem(r2); } } Answer posted by Support on Oct 22, 2008 09:46 Which version of grid you are using? There is known issues with complex math in case of dhtmlxgrid 1.6, which was fixed in version 2.0 ( you can contact us for related updated at support@dhtmlx.com ) In your code snippet, all code paths, which set =sum value commented, is it correct? You are changing type of cell to the "ed", when need to make it normal, but to change it bath to autocalculated, setting =sum is not enough, you need to use mygrid.setCellExcellType(some,some,"math"); //necessary to switch back from ed mygrid.cells(some,some).setValue("=sum"); Answer posted by Dennis on Oct 23, 2008 05:18 I am using version 1.6 with the version 2.0 editions of the files - dhtmlxgrid - dhtmlxcommon - dhtmlxgridcell - dhtmlxgrid_math I also tested it in version 2.0 which gave the same problem. the 'mygrid.setCellExcellType(some,some,"math");' solution didn't help. I think the problem lies in the refreshing of the =sum-cell when a table is dragged or added underneath a cell which isn't a parent yet. More ideas ? Best Regards, Dennis Pullens Answer posted by Support on Oct 23, 2008 06:32 If cell in question has a "math" type it must treate the =sum as math formula, so for items without sub-items it will result in empty value. If the cell has not "math" type , the value which you set will be rendered as is "=sum" Then cell changed in math column, for which "=sum" was defined, it will trigger data update for whole column , but grid must update only cells with math value and skip other types. If issues still occurs - please provide any kind of sample or link to the demo page, where issue can be reconstructed. ( you can send such info directly to support@dhtmlx.com ) |