Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. JqxTree control is taking time to load with 500 records

JqxTree control is taking time to load with 500 records

Scheduled Pinned Locked Moved JavaScript
javascriptjsonperformancequestion
5 Posts 5 Posters 19 Views 1 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.
  • Y Offline
    Y Offline
    yadta
    wrote on last edited by
    #1

    It is taking around 3-4 seconds to load 500 records which is very slow as it is hampering my app performance.

    var source = { datatype: "json",
    datafields: [ { name: "Rid", type: "int" },
    { name: "ParentRid", type: "int" },
    { name: "Name", type: "string" },
    { name: "Text", type: "string" } ],
    id : "Rid",
    localdata : dataSource,
    async: true,
    hasThreeStates: false };

    var dataAdapter = new $.jqx.dataAdapter(source);
    dataAdapter.dataBind();

    var records = dataAdapter.getRecordsHierarchy("Rid", "ParentRid", "items", [{ name: "Text", map: "label" }, { name: "Rid", map: "value" }, { name: "Name", map: "Name" }]);

    $("#jqxtree").jqxTree({ checkboxes: true, source: records, width: '100%', height: 220 });
    

    I want to load 'JqxTree' control in such a way that other things won't wait for it to load. Is there any way in the jQuery to load 'JqxTree' control in the background?

    Or something we can do which won't affect performance of whole application

    Richard DeemingR S P 3 Replies Last reply
    0
    • Y yadta

      It is taking around 3-4 seconds to load 500 records which is very slow as it is hampering my app performance.

      var source = { datatype: "json",
      datafields: [ { name: "Rid", type: "int" },
      { name: "ParentRid", type: "int" },
      { name: "Name", type: "string" },
      { name: "Text", type: "string" } ],
      id : "Rid",
      localdata : dataSource,
      async: true,
      hasThreeStates: false };

      var dataAdapter = new $.jqx.dataAdapter(source);
      dataAdapter.dataBind();

      var records = dataAdapter.getRecordsHierarchy("Rid", "ParentRid", "items", [{ name: "Text", map: "label" }, { name: "Rid", map: "value" }, { name: "Name", map: "Name" }]);

      $("#jqxtree").jqxTree({ checkboxes: true, source: records, width: '100%', height: 220 });
      

      I want to load 'JqxTree' control in such a way that other things won't wait for it to load. Is there any way in the jQuery to load 'JqxTree' control in the background?

      Or something we can do which won't affect performance of whole application

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      The obvious question is why are you trying to load 500 records into a tree? Are your users really going to dig through that many tree nodes to find the one they want? Surely there must be a better way to help them find what they're looking for? Beyond that, you need to profile your code to find out where the bottleneck is. If it really is the call to the jqxTree method, then the problem is likely the browser struggling to handle DOM updates, and there will be nothing you can do to improve that. You would need support from the authors of the library, which means waiting for them to reply to your GitHub issue[^].


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      J 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        The obvious question is why are you trying to load 500 records into a tree? Are your users really going to dig through that many tree nodes to find the one they want? Surely there must be a better way to help them find what they're looking for? Beyond that, you need to profile your code to find out where the bottleneck is. If it really is the call to the jqxTree method, then the problem is likely the browser struggling to handle DOM updates, and there will be nothing you can do to improve that. You would need support from the authors of the library, which means waiting for them to reply to your GitHub issue[^].


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        J Offline
        J Offline
        jschell
        wrote on last edited by
        #3

        Richard Deeming wrote:

        why are you trying to load 500 records into a tree?

        Good question. I have seen others try to load 3,000 and even 300,000. First one is when I learned years ago as a backend developer to never write queries that do not have a paging limit. At least that way if the front end tries to load everything it won't blow up my code.

        1 Reply Last reply
        0
        • Y yadta

          It is taking around 3-4 seconds to load 500 records which is very slow as it is hampering my app performance.

          var source = { datatype: "json",
          datafields: [ { name: "Rid", type: "int" },
          { name: "ParentRid", type: "int" },
          { name: "Name", type: "string" },
          { name: "Text", type: "string" } ],
          id : "Rid",
          localdata : dataSource,
          async: true,
          hasThreeStates: false };

          var dataAdapter = new $.jqx.dataAdapter(source);
          dataAdapter.dataBind();

          var records = dataAdapter.getRecordsHierarchy("Rid", "ParentRid", "items", [{ name: "Text", map: "label" }, { name: "Rid", map: "value" }, { name: "Name", map: "Name" }]);

          $("#jqxtree").jqxTree({ checkboxes: true, source: records, width: '100%', height: 220 });
          

          I want to load 'JqxTree' control in such a way that other things won't wait for it to load. Is there any way in the jQuery to load 'JqxTree' control in the background?

          Or something we can do which won't affect performance of whole application

          S Offline
          S Offline
          Secretsinnersuk2
          wrote on last edited by
          #4

          To improve the performance of your application and ensure that other components do not wait for the JqxTree control to load, you can load the JqxTree control asynchronously. One way to achieve this is by using JavaScript's `setTimeout()` function to delay the creation of the JqxTree control until after the initial rendering of the page. Here's how you can modify your code:

          ```javascript
          var source = {
          datatype: "json",
          datafields: [
          { name: "Rid", type: "int" },
          { name: "ParentRid", type: "int" },
          { name: "Name", type: "string" },
          { name: "Text", type: "string" }
          ],
          id: "Rid",
          localdata: dataSource,
          async: true,
          hasThreeStates: false
          };

          var dataAdapter = new $.jqx.dataAdapter(source);

          // Delay the creation of JqxTree control asynchronously
          setTimeout(function() {
          dataAdapter.dataBind();
          var records = dataAdapter.getRecordsHierarchy("Rid", "ParentRid", "items", [
          { name: "Text", map: "label" },
          { name: "Rid", map: "value" },
          { name: "Name", map: "Name" }
          ]);

          $("#jqxtree").jqxTree({
              checkboxes: true,
              source: records,
              width: '100%',
              height: 220
          });
          

          }, 0);
          ```

          By wrapping the creation of the JqxTree control inside `setTimeout()` with a delay of 0 milliseconds, you allow other components to load without waiting for the JqxTree control. This way, the JqxTree control will be loaded asynchronously, improving the overall performance of your application.

          Secret Sinners

          1 Reply Last reply
          0
          • Y yadta

            It is taking around 3-4 seconds to load 500 records which is very slow as it is hampering my app performance.

            var source = { datatype: "json",
            datafields: [ { name: "Rid", type: "int" },
            { name: "ParentRid", type: "int" },
            { name: "Name", type: "string" },
            { name: "Text", type: "string" } ],
            id : "Rid",
            localdata : dataSource,
            async: true,
            hasThreeStates: false };

            var dataAdapter = new $.jqx.dataAdapter(source);
            dataAdapter.dataBind();

            var records = dataAdapter.getRecordsHierarchy("Rid", "ParentRid", "items", [{ name: "Text", map: "label" }, { name: "Rid", map: "value" }, { name: "Name", map: "Name" }]);

            $("#jqxtree").jqxTree({ checkboxes: true, source: records, width: '100%', height: 220 });
            

            I want to load 'JqxTree' control in such a way that other things won't wait for it to load. Is there any way in the jQuery to load 'JqxTree' control in the background?

            Or something we can do which won't affect performance of whole application

            P Offline
            P Offline
            Prestige Somerville live
            wrote on last edited by
            #5

            Thank you for the information.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups