2014-07-07 50 views
2

我與使用一種稱爲回調功能SQLite數據庫中的數據網格作業時,在本課中描述修復與SQLite數據庫的數據網格變線高度:displaying-large-amounts-of-data如何使用回調

我想對該課程中包含的示例堆棧進行一些更改(您可以從該頁面頂部的鏈接下載堆棧)。

我想顯示在DG而不是電影的情節文本的「標題」的「陰謀」的文字應該有變線的高峯,因爲在這一課描述:how-do-i-create-a-form-with-variable-line-heights

在樣本棧我做了這些變化:

在行模板: 改名場「標題」到「暗算」,設置dontWrap爲false,並改變fixedLineHeight假

改名場「RELEASEDATE」到「NR」

補充說: 把我的領域「NR」來pDataArray [「身份證」]

在行行爲的文字:在設置變量行高度

## changed the layoutControl to make space for wrapping of field "plot" 

    on LayoutControl pControlRect 
    local theFieldRect 

    put the rect of me into theFieldRect 
    set the right of button "Genre" of me to item 3 of theFieldRect 
    set the right of field "LblGenre" of me to the left of button "Genre" of me 

    set the right of field "nr" of me to item 3 of theFieldRect 

    ## Expand field "plot" 
    put the rect of field "plot" of me into theFieldRect 
    put item 3 of pControlRect - 180 into item 3 of theFieldRect 
    set the rect of field "plot" of me to theFieldRect 

    ##Now resize field to fit content 
    put item 2 of theFieldRect \ 
     + the formattedheight of field "plot" of me - \ 
     the bottommargin of field "plot" of me \ 
    into item 4 of theFieldRect 
    set the rect of field "plot" of me to theFieldRect 

    ## Now update the bounding rect to match total height you 
    ## want this row to have 
    put item 4 of theFieldRect into item 4 of pControlRect 

    set the rect of graphic "Background" of me to pControlRect 
end LayoutControl 

在教訓它說轉關閉數據網格的「固定控制高度」。但是,當我這樣做沒有得到顯示,我得到一個腳本錯誤。

帶有我所做更改的堆棧位於:Databases-callbacks-variable-line-height.zip (只需用課程替換課程中的原始堆棧; SQLite數據庫是相同的,應放置在與堆棧相同的文件夾中)。

如何解決這個問題,以便可變的線高度工作?

回答

1

我找到了關閉固定控制高度的問題。在緩存每行高度時,數據網格行爲不會正確設置GetDataForLine pLine參數。我將提供對數據網格行爲的修改,直到LiveCode中包含修復程序,但您應該重新考慮您的方法。當固定線高度關閉時,數據網格必須在顯示數據網格之前計算每條線的高度。對於您正在使用的50,000條記錄示例,這需要花費大量時間。

首先,編輯數據網格行爲的腳本:

edit script of btn "data grid" of stack "revdatagridlibrary" 

接下來,轉到行3097 3097下方添加以下代碼行:

add 1 to theSequence 

代碼現在看起來應該像這樣:

repeat for each key theIndex in sDataArray  
      add 1 to theSequence 

      ## Get height 
      if sDataArray[theIndex] is NULL then 

保存腳本。這將保存您當前版本的LiveCode中的更改。請注意,下次您更新LiveCode時,更改將會丟失。然而,我將修復提交給RunRev,因此它應該在下一個版本中修復。

此外,設置圖形「背景」矩形的代碼需要稍作更改。現在,如果字段的底部高於「流派」按鈕的底部,它將不起作用。代碼也許應該是這樣的:

put max(item 4 of theFieldRect, the bottom of button "Genre" of me + 4) into item 4 of pControlRect 
+0

它現在確定的,但正如你所說的這是非常緩慢的繪製50000個記錄列表 - 花了大約5分鐘。 (!)在一個Android平板電腦,否則很快(只有1100個記錄,它花了7秒,這也是太慢)。所以這種方法是慢的,但是你跟蹤bug是很好的。我想測試這種方法,主要是在我正在開發的應用中比較滾動速度和原生Android滾動條。它有大約700條記錄,正在使用標準LC數據網格,它從製表符分隔的文本文件中獲取其數據....在下一條評論中繼續。 – keram

+0

該應用程序的滾動速度很慢,因此我正在尋找不同的方法來加速並使其更具響應性。如果你有一些時間看我的堆棧(它是自包含的,沒有任何外部文件需要),那麼我會很感激有關如何加快其滾動的任何建議。鏈接到我的應用程序:[DG-only-1.16.zip](https://www.dropbox.com/s/xs0pcrwvh1cc74h/DG-only-1.16.zip) 要測試其數據網格滾動,請點擊「全選「,然後是」行「,然後是」整個選擇「。 – keram

+0

我實際上爲滾動速度問題創建了一個新問題:[scrolling_speed](http://stackoverflow.com/questions/24627756/how-to-increase-the-speed-of-the-native-android-scroller數據網格);我忘記在上面的評論中提到,使用回調功能時,使用這50000條記錄滾動DG會更好。 – keram