Vertical Paging
Timeline Views offer two types of vertical paging. The first type can be seen in the example above. The only thing the developer needs to do is specify the number of items per page by setting VerticalPageSize attribute. Most use cases can easily be addressed by using VerticalPageSize.
However, this approach is not suitable for large datasets since paging occurs after the time line data is fetched. Additionally, this applies paging only at the root level of a column hierarchy, which can still fetch hundreds or thousands of rows if it is a multi-level hierarchy!
The second type of paging is done with the help of a SQL query and a TLVPage macro. This more performant approach requires the developer to follow these three steps:
Define a paging SqlDef.
<
SqlDef
Name
=
"PagingSql"
GroupName
=
"TlvSqls"
>
<![CDATA[
SELECT DISTINCT sys_item_id, sys_site_id FROM item_by_site
ORDER BY sys_item_id, sys_site_id
]]>
</
SqlDef
>
The paging SQL query must select all columns up to the page break level. For example, the query above will apply paging on the site level instead of item. If the query is updated to fetch only item from the table, then paging will be applied at the item level. Also, the returning values need to be distinct and should be sorted in the same order. (Columns need not be exactly the same as the ColumnHierarchy columns.)
Reference your paging SqlDef using VerticalPagingSqlDef.
<
ColumnHierarchy
>
<
VerticalPageSize
>5</
VerticalPageSize
>
<
VerticalPagingSqlDef
>PagingSql</
VerticalPagingSqlDef
>
Insert the TLVPage macro into all your Datameasure SqlDefs.
SELECT item, sys_item_id item_id, site, sys_site_id site_id, the_date, quantity FROM item_by_site
WHERE ${TLVPage:item_id,site_id}
TLVPage macro with the help of paging query will apply paging to the returning results. As mentioned earlier, columns returned by the paging query do not have to match columns defined in the macro. There is no limit on the number of columns as long as the number of columns in the macro is equal to the number of columns provided in the paging query.
Even though the columns do not have to match, they do need to have a logical relationship. For example, ${TLVPage:site_id,item_id} in our example will work but won't return any results since the order of columns is not consistent with the ColumnHierarchy definition.
Let's look at the complete example and how it appears in the UI.
<
TLVList
xmlns
=
"http://www.onenetwork.com/Platform"
>
<
TLV
>
<
Name
>ColumnHierarchyTLV</
Name
>
<
Bucketization
>DAILY</
Bucketization
>
<
BucketsPerPage
>7</
BucketsPerPage
>
<
SqlDef
Name
=
"PagingSql"
GroupName
=
"TlvSqls"
>
<![CDATA[
SELECT DISTINCT sys_item_id, sys_site_id FROM item_by_site
ORDER BY sys_item_id, sys_site_id
]]>
</
SqlDef
>
<
SqlDef
Name
=
"DataSql"
GroupName
=
"TlvSqls"
>
<![CDATA[
SELECT item, sys_item_id item_id, site, sys_site_id site_id, the_date, quantity FROM item_by_site
WHERE ${TLVPage:item_id,site_id}
]]>
</
SqlDef
>
<
SqlDef
Name
=
"AttSql"
GroupName
=
"TlvSqls"
>
<![CDATA[
SELECT item, site, site_id, site_desc, site_desc2, site_desc3 FROM item_by_site_info
]]>
</
SqlDef
>
<
Filters
bindSqlNulls
=
"true"
>
<
CustomFilterField
>
<
FieldRef
category
=
"PDF"
levelType
=
"Undefined"
>
<
FieldName
>DateRange</
FieldName
>
</
FieldRef
>
<
Hidden
>false</
Hidden
>
<
Editable
>true</
Editable
>
<
Type
>DATE_RANGE</
Type
>
<
Optional
>false</
Optional
>
<
DateRangeMapping
fromSqlName
=
"DATE_RANGE_START"
toSqlName
=
"DATE_RANGE_END"
/>
</
CustomFilterField
>
<
DateRange
start
=
"$NULL$"
end
=
"$NULL$"
/>
</
Filters
>
<
ColumnHierarchy
>
<
VerticalPageSize
>5</
VerticalPageSize
>
<
VerticalPagingSqlDef
>PagingSql</
VerticalPagingSqlDef
>
<
Column
>
<
Name
>item</
Name
>
</
Column
>
<
Column
>
<
Name
>site</
Name
>
<
Attribute
hidden
=
"true"
>
<
Name
>site_id</
Name
>
<
SqlDefName
>AttSql</
SqlDefName
>
</
Attribute
>
<
Attribute
>
<
Name
>site_desc</
Name
>
<
SqlDefName
>AttSql</
SqlDefName
>
</
Attribute
>
<
Attribute
>
<
Name
>site_desc2</
Name
>
<
SqlDefName
>AttSql</
SqlDefName
>
</
Attribute
>
<
Attribute
>
<
Name
>site_desc3</
Name
>
<
SqlDefName
>AttSql</
SqlDefName
>
</
Attribute
>
</
Column
>
</
ColumnHierarchy
>
<
DM
bucketization
=
"DAILY"
editable
=
"true"
>
<
Name
>DMA</
Name
>
<
DisplayName
>DM A</
DisplayName
>
<
SqlDefName
>DataSql</
SqlDefName
>
<
SqlQuantityField
levelType
=
"Undefined"
>
<
FieldName
>quantity</
FieldName
>
</
SqlQuantityField
>
<
SqlDateField
levelType
=
"Undefined"
>
<
FieldName
>the_date</
FieldName
>
</
SqlDateField
>
</
DM
>
</
TLV
>
</
TLVList
>
Note that the first page only had Item01 through Item04 instead of Item05 even though VerticalPageSize is still set to 5. We designed our paging in a way to apply paging at the site level so only 5 sites and 4 items are shown on the first page.