Order of items in a Palette

Hi.

I have a problem with my Palette.
When I show the subsetPaletteItems which contains my most common items, the items are displayed correctly in my specified order.

However, when I change to allPaletteItems, the items are not following my order anymore. For some reason, the “Pentagon” is displayed at the top, and the “Ellipse” is moved far down the line. How come? Can this be fixed? I need the items to appear in the order I specify them.

Subset-Palette as it is displayed in the correct order.


And the All-Palette as it is displayed with incorrect order. The first 6 items should be displayed in the same order as the Subset-Palette!


My code looks like this:

function initPalette() {
window.allPaletteItems = new go.GraphLinksModel([
{ figure: “Border” },
{ figure: “Ellipse” },
{ figure: “Decision” },
{ figure: “SquareArrow” },
{ figure: “Document” },
{ category: “Line” },
{ category: “Spacer” },
{ category: “Button”, text: “<<<”, showingAll: “true” },
{ figure: “Triangle” },
{ figure: “Pentagon” },
{ figure: “Hexagon” },
{ figure: “Octagon” },
{ figure: “Decagon” },
{ figure: “Database” },
{ figure: “File” },
{ figure: “StopSign” },
{ figure: “Procedure” },
{ figure: “Cloud” }
]);

window.subsetPaletteItems = new go.GraphLinksModel([
{ figure: “Border” },
{ figure: “Ellipse” },
{ figure: “Decision” },
{ figure: “SquareArrow”},
{ figure: “Document” },
{ category: “Line” },
{ category: “Spacer” },
{ category: “Button”, text: “>>>”, showingAll: “false” }
]);

window.myPalette = new go.Palette(“modelPalette”);
window.myPalette.maxSelectionCount = 1;
}

function loadPalette() {
window.myPalette.model = window.subsetPaletteItems;
}

function buttonEvent(e, obj) {
var node = obj.part;
var data = node.findObject(“STATUS”);
if (data) {
if (data.text == “false”) {
myPalette.model = allPaletteItems;
document.getElementById(‘modelPalette’).style.height = ‘500px’;
} else {
myPalette.model = subsetPaletteItems;
document.getElementById(‘modelPalette’).style.height = ‘250px’;
}
}
}

It depends on your templates.

Try setting myPalette.layout.sorting = go.GridLayout.Forward.

I am guessing that you have not set/bound Part.text, so the default sorting will sort all of the nodes in an indeterminate order.

Thanks. This worked well.