Categories | Question details Back To List | ||
Grid math calculations calaultions on gris cells may result erros, how can I manage or catch errors. (like to avoid N.an display when dividing by 0)? Answer posted by dhxSupport on Feb 25, 2009 05:13 You can get cell's value with method mygrid.cellById(rowId,cellIndex).getValue() and then check if this value valid or not. You should make this validation after grid was fully loaded. To detect if grid was filly loaded you can use "onXLE" evet (availible at PRO vestion only) or 2nd parameter on loadXML method: mygrid.loadXML("grid.xml",function(){ //make validation }) Answer posted by Support on Feb 25, 2009 05:17 Also, custom methods can be used in formulas. Instead of <cell>=c1/c2</cell> You can use <cell>=my_operation(c1,c2)</cell> and define in JS code function my_operation(c1,c2){ if (c2) return c1/c2; return "error"; } Answer posted by Zafrir Ron on Feb 25, 2009 06:20 Ok, Thanks, but is it possible to make this on the init statement : ( mygrid.setColTypes("tree,ron,ron,ron,price,ron[=my_operation(c1,c2)],ron[=c3/c2*100],price[=c4/c1*1000],price[=c4/c2*100],price[=c4/c3]"); since I want to avoid this from the server. it looks like a parsing error or something else preventing using this method. Thanks, Zafrir Ron (license 256976565) Answer posted by Support on Feb 25, 2009 08:07 The tricky point is the commas inside the custom methods - they are the same as string separators, so string parsed incorrectly You can use mygrid.setDelimiter("|"); mygrid.setColTypes("tree|ron|ron|ron|price|ron[=my_operation(c1,c2)]|ron[=c3/c2*100]|price[=c4/c1*1000]|price[=c4/c2*100]|price[=c4/c3]") mygrid.setDelimiter(","); Answer posted by ZAfrir Ron on Feb 25, 2009 23:35 Great, Thanks, it did solve my problem!! |