Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Menu sort

    SmartClient Version: v13.0p_2024-01-04/AllModules Development Only (built 2024-01-04)

    Hello, is sorting on dataBound menus actually supported?

    If I add sortField to the treeBinding sample, it doesn't seem to work:

    Code:
    isc.Tree.create({
        ID: "menuTree",
        root: {name: "root", children: [
            {name: "Marketing", children: [
                {name: "Advertising"},
                {name: "Community Relations"}
            ]},
            {name: "Sales", children: [
                {name: "Channel Sales"},
                {name: "Direct Sales"}
            ]},
            {name: "Manufacturing", children: [
                {name: "Design"},
                {name: "Development"},
                {name: "QA"}
            ]},
            {name: "Services", children: [
                {name: "Support"},
                {name: "Consulting"}
            ]}
        ]}
    });
    
    var departmentButton = isc.MenuButton.create({
        autoDraw: false,
        title: "Go to department",
        width: 160,
        menu: isc.Menu.create({
            data: menuTree,
            canSelectParentItems: true,
            itemClick: function (item) {
                isc.say("You picked the \""+item.name+"\" department.");
            }
        })
    });
    
    var categoryButton = isc.MenuButton.create({
        autoDraw: false,
        title: "Go to category",
        width: 160,
        menu: isc.Menu.create({
            dataSource: "supplyCategory",
            canSelectParentItems: true,
            sortField:"-categoryName",
            itemClick: function (item) {
                isc.say("You picked the \""+item.categoryName+"\" category.");
            }
        })
    });
    
    isc.HStack.create({
        width: "100%",
        members: [
            isc.VStack.create({
                autoDraw: false,
                membersMargin: 10,
                members: [departmentButton, categoryButton]
            })
        ]
    });

    #2
    Hi claudiobosticco,

    I’m not sure it is meant to work this way (-fieldName).
    sortField takes a field name, and then there is also sortDirection.

    Best regards
    Blama

    Comment


      #3
      thanks for the heads up Blama, using sortDirection it's working.
      Last edited by claudiobosticco; 4 Jan 2024, 13:24.

      Comment


        #4
        hi Claudio,

        Menu-sorting generally works - a regular, non-databound, non-tree menu, for example, can be sorted by title with sortField and sortDirection.

        In the sample you pointed to, the first tree is not sortable because it uses the children-array model. But the second one, which is databound, can indeed be sorted on, for example, "categoryName" in either direction, via sortField and sortDirection.

        Comment

        Working...
        X