242
个编辑
Willson-v-(讨论 | 贡献) 无编辑摘要 |
Willson-v-(讨论 | 贡献) 无编辑摘要 |
||
第146行: | 第146行: | ||
-- extract row_ids in each tables | -- extract row_ids in each tables | ||
-- i hate lua why array subscribtion starts at 1 | -- i hate lua why array subscribtion starts at 1 | ||
local | local tot_row_ids = {} | ||
local item_per_tab = tonumber(params["item_per_tab"]) | local item_per_tab = tonumber(params["item_per_tab"]) | ||
for k, _ in pairs(args) do | for k, _ in pairs(args) do | ||
local anum = ('' .. k):match('^a(%d+)$') | local anum = ('' .. k):match('^a(%d+)$') | ||
if anum then | if anum then | ||
if | table.insert(tot_row_ids, tonumber(anum)) | ||
end | |||
end | |||
table.sort(tot_row_ids) | |||
local tabs_row_ids = {} | |||
for i, id in ipairs(tot_row_ids) do | |||
if i % item_per_tab == 0 then | |||
tabs_row_ids[i / item_per_tab + 1] = {} | |||
end | end | ||
table.insert(tabs_row_ids[i / item_per_tab + 1], id) | |||
end | end | ||
-- if only one table is needed... | -- if only one table is needed... |