Faster way to clear a node - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Faster way to clear a node

Last post 07-29-2007 09:54 AM by Matt Faus. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 07-26-2007 11:31 PM

    Faster way to clear a node

    Hi all,

    my users search for products in a database, and I want to allow my user to clear the repeating table of search results. So I have a button with this code:

    // now clear the query results table
    objSource = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields" );
    var allTheNodes = objSource.selectNodes("//d:Products");
    for (var i=0; i<allTheNodes.length; i++) {
        Item = allTheNodes.item(i);
        objSource.removeChild(Item);
    }

    This works fine if my repeating table showing the products only has a couple of entries. Once the number of entries is huge (100+, I would say), INFOPATH.EXE consumes 50% CPU for minutes, and most of the time I have to kill the process since it never seems to return.

    Is there a faster and mroe performant way to remove all child nodes ?

    Cheers

    moe 

     

     

     

  • 07-27-2007 04:31 AM In reply to

    Re: Faster way to clear a node

    Hi moestavern,

    Yes.  I'm not sure the exact syntax in JScript, but the IXMLDOMSelection class has a removeAll() method that I always use when doing something like this.  I haven't run numbers or encountered a problem like this, but it should be faster.

    Try this:

    allTheNodes.removeAll();

    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 07-27-2007 04:53 AM In reply to

    Re: Faster way to clear a node

    Hi Matt,

    yes,  

    allTheNodes.removeAll();

    is valid JScript.

    However, the behaviour is the same. Seems to me as if

    allTheNodes.removeAll();

    internally performs the same for loop with removeChild that I did before.

    Cheers

    Stefan

  • 07-27-2007 05:16 AM In reply to

    Re: Faster way to clear a node

    I Played around a little, removing 100 child nodes still has acceptable performance (a couple of secs), however deleting 300 (or even 1100) nodes takes several minutes with a white-screen-non-responding infopath ;-(
  • 07-27-2007 09:04 AM In reply to

    Re: Faster way to clear a node

    Yes, 1100 nodes on any single InfoPath view will cause huge performance hits.  You should use paging  to only show 20 rows at a time, or when you are deleting, switching to another "Deleting" page while the delete operation runs, and then switch back after it is done.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 07-29-2007 09:45 AM In reply to

    Re: Faster way to clear a node

    Hi Matt,

    does the repeating table control have the ability to do paging, or do I need to use views ?

    I am using Infopath 2003.

     cheers

    moe

  • 07-29-2007 09:54 AM In reply to

    Re: Faster way to clear a node

    Unfortunately, you will have to implement paging on your own.  We have discussed this countless times on the forums - try searching around a bit.  We also have a few blog posts that cover this, I think.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.