在舊的Lasso 8代碼中,我經常在條件中使用field('foo', -recordindex=(loop_count - 1))
,以便在記錄之間更改值時在表中顯示標題行。在Lasso 9中,field方法的-recordindex參數是否存在?備擇方案?
在Lasso 9中,-recordindex
參數似乎被忽略。它也沒有記錄。
我的第一個解決方法是爲每個記錄迭代設置一個變量,並將當前記錄的字段與該值進行比較。
<?= var('lastSortFieldValue') = null ?>
[records]
[if(field('sortField') != $lastSortFieldValue)]
<!-- display header -->
[/if]
<!-- display row -->
<?= $lastSortFieldValue = field('sortField') =>
[/records]
這裏的最佳實踐的任何建議?提前感謝您的時間和幫助。
-Justin
非常有益的工作,各地的地方637
結果!感謝您的自定義方法。我把它放在我的實例的LassoStartup中,並迅速將所有出現的舊方式轉換爲臨時的新方式。你如何找到所有這些祕密類型和方法,如inline_scopeGet和INLINE_RESULTROWS_POS? :-) –
我同意Jolle,而優雅的解決方案不必要地增加開銷。賈斯汀,你的第一個方法可能是最有效的。 –
我也同意Jolle和Ke - 使用這種方法來使事情有效,但正如上面所說的,使用變量的解決方案是最好的方法。 (順便說一句,我的解決方案可以通過不使用列來抓取數據而加快速度,但這可能會在邊緣情況下導致意外的結果。) – bfad