setSort (method, dimAttrId, fireEvent);
method. Sets sorting type. Parameter value – element of the PP.Ui.TreeListSort enumeration.
dimAttrId. Sets identifier of dimension attribute based on which the data will be sorted.
fireEvent. Indicates whether to fire the TreeSortChanged event, By default this parameter is set to True.
The setSort method sets a sorting method.
To execute the example, the page must contain the WorkbookBox component named workbookBox (see Example of Creating the WorkbookBox Component), and also add the following code in the handler, that processes document opening event:
var brCr = workbookBox.getDataView().getBreadcrumb();
var mattr = brCr.getMetaAttributes().getItem(0);
var item = mattr._BreadcrumbItem;
//Get the PP.TS.Ui.MetaAttribute object by attribute identifier
var metaattr = brCr.getMetaAttributeById(item.getId());
//Get drop-down panel corresponding to attribute from the obtained attribute
var panel = metaattr.getDropPanel();
//Expand panel
showPanel();
var setSortButt = new PP.Ui.Button({
ParentNode: document.body, //DOM parent node
Content: "Change sorting", //Text
Click: PP.Delegate(onClickSetSort)
});
var order;
var sort = true;
function onClickSetSort(){
if (sort)
{
order = 1;
//Set sorting
metaattr.setSort(order, "NAME");
metaattr.getTree().sort("NAME", order);
}
else
{
order = 2;
//Set sorting
metaattr.setSort(order, "NAME");
metaattr.getTree().sort("NAME", order);
}
sort = !sort;
showPanel();
}
//Sorting is changed on double click
function showPanel()
{
//Calculate coordinates of top left corner of drop-down panel
var visibilityObject = panel.isVisibleArea(0, 0);
//Calculate offset
var coords = PP.calculateOffset(item._DomNode);
//Calculate Y axis coordinate
var top = coords.Y + item._DomNode.offsetHeight + 1;
var left = 0;
if (brCr.getIsRTL())
//Calculate X axis coordinate
left = coords.X + item._DomNode.offsetWidth - visibilityObject.Width + 1;
else
//Calculate Y axis coordinate
left = coords.X - 1;
//Display the panel
panel.show(left, top);
}
After executing the example the HTML page contains expanded panel of the breadcrumb first attribute and a button named Change Sorting. Double click on this button changes the type of sorting for attribute elements in the expanded panel.
See also: