Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. List of JavaScript Objects and Functions
Qt 6.11 is out! See what's new in the release blog

List of JavaScript Objects and Functions

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 2 Posters 2.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Diarby
    wrote on last edited by
    #1

    Hi everyone,
    I need to sort a JS array of objects like this { productId : "", product : "", price : 0, rebate : "", description: "" }
    This is my code :
    source.sort(function(a,b){
    return a.product.toLocaleLowerCase().localCompare(b.product.toLocaleLowerCase())
    });
    When running, I got this error :
    Starting /home/diarby/studio/qt/projects/build-test-Desktop_Qt_5_10_0_GCC_64bit-Debug/qtc_Desktop_Qt_5_10_0_GCC_64bit_Debug/install-root/test...
    qrc:/datasource.js:1277: TypeError: Property 'localCompare' of object orange is not a function

    Here, orange is the value of product property. and source is the array.
    In the manual, it is said that ECMA-262 is supported and localCompare() is really a function.

    How can I do array sorting on basis of string objects ?

    JKSHJ 1 Reply Last reply
    0
    • D Diarby

      Hi everyone,
      I need to sort a JS array of objects like this { productId : "", product : "", price : 0, rebate : "", description: "" }
      This is my code :
      source.sort(function(a,b){
      return a.product.toLocaleLowerCase().localCompare(b.product.toLocaleLowerCase())
      });
      When running, I got this error :
      Starting /home/diarby/studio/qt/projects/build-test-Desktop_Qt_5_10_0_GCC_64bit-Debug/qtc_Desktop_Qt_5_10_0_GCC_64bit_Debug/install-root/test...
      qrc:/datasource.js:1277: TypeError: Property 'localCompare' of object orange is not a function

      Here, orange is the value of product property. and source is the array.
      In the manual, it is said that ECMA-262 is supported and localCompare() is really a function.

      How can I do array sorting on basis of string objects ?

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @Diarby said in List of JavaScript Objects and Functions:

      qrc:/datasource.js:1277: TypeError: Property 'localCompare' of object orange is not a function

      Here, orange is the value of product property. and source is the array.
      In the manual, it is said that ECMA-262 is supported and localCompare() is really a function.

      Do you mean localeCompare()?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      2
      • D Offline
        D Offline
        Diarby
        wrote on last edited by
        #3

        Hello, yes I do. Please see my code on top.
        I just copied and pasted "as is" the error message received from the application.

        JKSHJ 1 Reply Last reply
        0
        • D Diarby

          Hello, yes I do. Please see my code on top.
          I just copied and pasted "as is" the error message received from the application.

          JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #4

          @Diarby

          1. localeCompare()
          2. localCompare()

          You need #1 but you wrote #2

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          2
          • D Offline
            D Offline
            Diarby
            wrote on last edited by
            #5

            Oh my God ! Thanks for your help. I was really bad there.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved