Announcement

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

    Sorting of menu items

    Hi,

    I have question about sorting of Menu. Because I have menu with dynamic items, and I need to sort these menu items. I tried to use standard sortField and sortDirection attributes from ListGrid. It works somehow, but menu generate warning message into console:
    WARN:Menu:menu:fields and completeFields are null and there is no DataSource
    So I think it is not correct way, or there is bug.
    You can see it on this example:
    Code:
    isc.Menu.create({
        ID: "menu",
        autoDraw: false,
        showShadow: true,
        shadowDepth: 10,
    sortField: "title", sortDirection: "ascending",
        data: [
            {title: "New", keyTitle: "Ctrl+N", icon: "icons/16/document_plain_new.png"},
            {title: "Open", keyTitle: "Ctrl+O", icon: "icons/16/folder_out.png"},
            {isSeparator: true},
            {title: "Save", keyTitle: "Ctrl+S", icon: "icons/16/disk_blue.png"},
            {title: "Save As", icon: "icons/16/save_as.png"},
            {isSeparator: true},
            {title: "Recent Documents", icon: "icons/16/folder_document.png", submenu: [
                {title: "data.xml", checked: true},
                {title: "Component Guide.doc"},
                {title: "SmartClient.doc", checked: true},
                {title: "AJAX.doc"}
            ]},
            {isSeparator: true},
            {title: "Export as...", icon: "icons/16/export1.png", submenu: [
                {title: "XML"},
                {title: "CSV"},
                {title: "Plain text"}
            ]},
            {isSeparator: true},
            {title: "Print", enabled: false, keyTitle: "Ctrl+P", icon: "icons/16/printer3.png"}
        ]
    });
    
    isc.MenuButton.create({
        ID: "menuButton",
        title: "File",
        width: 100,
        menu: menu
    });
    I am using SmartClient Version: v9.0p_2014-01-01

    Have you any idea how to do it correctly?

    Thanks.

    #2
    You haven't mentioned your SmartClient version - but please try using initialSort rather than sortField/Direction.

    Comment


      #3
      Sorry, you HAVE mentioned your SmartClient version :)

      But please still try initialSort.

      Comment


        #4
        I used this initial sort :
        Code:
        initialSort:[{property:"title", direction:"ascending"}]
        in my first example. And it doesn't work, it has no influence to items order.

        Comment


          #5
          Not reproducible against latest 9.0 - you can probably fix it by setting the default fields (see the doc for menu.fields) in your config, so they're available as required - but really you should retest with the latest from smartclient.com.

          Comment


            #6
            Thanks for your fast answers. But I tested this code:
            Code:
            isc.Menu.create({
                ID: "menu",
                autoDraw: false,
                showShadow: true,
                shadowDepth: 10,
            initialSort:[{property:"title", direction:"ascending"}],
                data: [
                    {title: "New", keyTitle: "Ctrl+N", icon: "icons/16/document_plain_new.png"},
                    {title: "Open", keyTitle: "Ctrl+O", icon: "icons/16/folder_out.png"},
                    {isSeparator: true},
                    {title: "Save", keyTitle: "Ctrl+S", icon: "icons/16/disk_blue.png"},
                    {title: "Save As", icon: "icons/16/save_as.png"},
                    {isSeparator: true},
                    {title: "Recent Documents", icon: "icons/16/folder_document.png", submenu: [
                        {title: "data.xml", checked: true},
                        {title: "Component Guide.doc"},
                        {title: "SmartClient.doc", checked: true},
                        {title: "AJAX.doc"}
                    ]},
                    {isSeparator: true},
                    {title: "Export as...", icon: "icons/16/export1.png", submenu: [
                        {title: "XML"},
                        {title: "CSV"},
                        {title: "Plain text"}
                    ]},
                    {isSeparator: true},
                    {title: "Print", enabled: false, keyTitle: "Ctrl+P", icon: "icons/16/printer3.png"}
                ]
            });
            You can see result on image. Menu items are not sorted.
            And I don't want to define default fields for menu, because menu already has some standard fields defined: isc.Menu.standardFields.
            Attached Files

            Comment


              #7
              Right - so, on later versions (including that week-old version you showed), switch back to using sortField - we'll investigate initialSort in this use case

              Comment

              Working...
              X