ruby-****@sourc*****
ruby-****@sourc*****
2012年 10月 15日 (月) 03:37:26 JST
------------------------- REMOTE_ADDR = 184.145.82.7 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-treev-cbbr ------------------------- @@ -139,13 +139,24 @@ + {{br}} +=== Avoiding the Excessive Use of Data Cell Functions +Remember in the paragraph 'Data Dependencies Between Cells In Different Columns And Rows In Tree View' in section [8.7.1.2] (see '((<Optimization Note|tut-gtk2-treev-crs#Optimization Note>))'), we warned against excessive use of cell data functions. In the example program there we hinted about eliminating the need to control the cells in 'Buy' column with its own data cell function. We suggested there to enable or disable user's access to the 'Buy' column while processing the 'Count' column by placing the following code after we updated the 'total' value in the product category record in the 'fix_parents_total' method: + + parent[BUY_COLUMN] = total == 0 ? false : true + +With the above addition we actually process two columns in a single data cell function rather than two, thus potentially improve program performance. Due to slightly compromised behaviour of the editable 'Buy' column there, this would introduce had we implemented it there, in section [8.7.1.2], we did not implement this optimization. However, here in our next 'combo-rndr-2.rb' example program, the 'Buy' column is not editable, hence, there is no possibility for the undesirable program behaviour in that column, which gives us the opportunity to implement the suggested optimization. + {{image_right("treev-combo-01.png")}} + +The following, therefore, is our old 'Grocery List' example with all the three columns, and indeed, with the combo box in the second 'Count' column. Because the 'Buy' column here is not editable, dropping off one of the two cell data function methods, used in 'toggle-rndr-2.rb' example in section [8.7.1.2], here in the following 'combo-rndr-2.rb' example does not have any adverse effect, namely there is no delay, and no auto-corrective action here. Let's look at the listing: + + -The following is our old 'Grocery List' example with all the three columns and, indeed with the combo box in the second 'Count' column. It is included mostly because, the way it is designed here, preventing a user from directly altering the 'Buy' column, it gives us the opportunity to implement the optimization we first mentioned under the paragraph (Data Dependencies Between Cells In Different Columns And Rows In Tree View) in section [8.7.1.2] (see '((<Optimization Note|tut-gtk2-treev-crs#Optimization Note>))' there). Because the 'Buy' column here is not editable, dropping off one of the two cell data function methods, used in 'toggle-rndr-2.rb' example in section [8.7.1.2], here in the following 'combo-rndr-2.rb' example does not have any adverse effect, namely there is no delay, and no auto-corrective action here. Let's look at the listing: