Search

Support

Discord

English

Search

Support

Discord

English

Examples

Integrate custom sorting in a table

Integrate Custom Sort in a Table

Do you want to sort your entries with the Custom Sort directly within the Custom Table? In this post, you will find a detailed guide on the Ninox settings you need and the corresponding application code. In the following example, a task list (Child / Sub-table) is displayed in an order (Parent / Main table) as a Custom Table. With Custom Sort, the order of tasks should be set manually.

Widgets you need for this:

Ninox settings you need:

  • a sortId function field in the task (child)

  • Sorting number field in the table where the records should be sorted

  • sortItems text field in the order (parent)

Application Code

let current := this;
arcCustomSort({
        uniqueId: Nr,
        editable: false,
        recordId: current.Nr,
        fieldId: "",
        direction: "horizontal",
        title: Sortierung,
        value: Sortierung,
        valuePrefix: number(Nr) + ",",
        size: "",
        color: "",
        showIconsAlways: true,
        iconStart: "",
        iconEnd: ""
    })

sortId function field in the task (Child)

let entities := Auftrag.Aufgaben;
if Sortierung != null then
    let sortValue := format(Sortierung, "000") + "-" +
        (number('Zuletzt geändert') - number(datetime(3000, 1, 1))) +
        "-" +
        number(Nr);
    number(cnt(entities[Sortierung != null and
            format(Sortierung, "000") + "-" +
                    (number('Zuletzt geändert') - number(datetime(3000, 1, 1))) +
                    "-" +
                    number(Nr) <= sortValue]))
else
    let sortValue := max(entities.Sortierung) + 1 + "" + Nr;
    number(cnt(entities[max(entities.Sortierung) + 1 + "" + Nr <= sortValue]))
end

sortItems text field in the order (Parent)

Insert the following code into your sortItems text field in the trigger after change.

let current := this;
if sortItems != null then
    let splitItem := split(sortItems, ",");
    let itemNr := item(splitItem, 0);
    let itemPos := item(splitItem, 1);
    let item := first(Aufgaben[number(Nr) = number(itemNr)]);
    item.(Sortierung := number(itemPos) +
        if itemPos > item.Sortierung then
            1
        else
            0
        end);
    for item in Aufgaben order by Sortierung do
        item.(Sortierung := item.sortId)
    end;
    sortItems := null
end



Arc Rider Ventures GmbH

© 2025

Arc Rider Ventures GmbH

© 2025