logo

New Response

« Return to the main article

You are replying to:

    • avatar
    • Andreja
    • Posted on Fri 24 Aug 2007

    Despite this is relatively old post, problem with searchorder remains the same. Recently I had to preserve sort order of a view when a view is searched on a web. I didn't have any solutions, so I decided to put some JavaScript to work - problem with this is that script itself is not generalized, so it can't be used as is for preserving searchorder on any view, and it gets more complicated if you want to sort by more than 1 column, but still concept is simple: On a "$$SearchTemplate for view" form, I nest the $$ViewBody field into a layer (<div>) with id attribute. At the end of that form I put a JavaScript function call, which selects all the table rows (<tr>) in nested table in div with specific id (because Domino shows search results as table). Then, an array (lets call it first array) is populated with the innerHTML of every tr element in that table. During this process, I also check the value of specific <td> innerHTML, which holds information crucial for sorting. In another array (lets call it second array), I put the content of innerHTML of <td> (specific column) and index of corresponding index of iteration which is actually the index of table row in which the specific <td> is situated. After this is done, you can resort the contents of second array by some criteria (ascending for example), by checking it's content. Now you got the order of indexes from first array in which the rows should appear. Change the content of innerHTML of <div> with specified id, with contents in first array in an order of indexes sorted in second array, and you get your searh results sorted. It's also necessary that div is styled display:none by default, and after sorting, at the end of JavaScript function, put that style of a div as display:block. That way you'll avoid the effect of "jumping" of html page.

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment: