Announcement

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

    Problem with grouped listgrid, CSV export and Cell formatters on non-rendered fields

    OK, scenario (see attached screenshot):

    I have a somewhat interactive report where data is shown in a grouped listgrid. The user can expand and collapse as he/she sees fit. There's a candybar with export icons that performs a "exportclientdata".

    My problem is that the cellformatter is only called for the cells when the tree nodes are expanded.

    If i, say, expand one node, but leave the others, i get the first node formatted prettily, but the others are not, making the csv look really strange.

    Is there any way to enforce the formatting, either on load or when i perform the export. I havent found anything.


    Would be great with some feedback. Cheers
    Attached Files

    #2
    You would need to open all the groups (openAll() on the groupTree).

    Comment


      #3
      Yeah, thats what i did in another report, but it looks really crappy to the end user if all suddenly expands on-screen when you click a seemingly unrelated icon...

      Is this really the only way? Would be great with a code hook or something when the data is sent.

      Comment


        #4
        You could easily re-collapse them after the export if you feel it's important.

        There is also exportData() instead of exportClientData(), which allows you to do whatever formatting you want server-side.

        Comment


          #5
          Yes, i did actually try that too. It looks really flaky with all expanding then collapsing, especially with larger data sets.

          So i guess that means that i'll have to do some coding to process the data server side... It feels bad to have to keep the same formatting rules in 2 places (my spring-webservices that will give back the data for the report, and the client-side cellformatters), but not much i can do apparently.


          As a sidenote, i feel that the documentation for this is somewhat misleading. From the exportclientdata javadoc:

          Code:
          Exports this component's data with client-side formatters applied, so is suitable for direct display to users. This feature requires the SmartClient server, but does not rely on any server-side DataSources.

          Given this, you'd expect all data in the component to be exported with formatters, since it doesn't say anything about having to be visible on-screen. Would have saved me time if it had been mentioned. Alternatively, i would have expected only the data visible to be part of the export, not a mash-up as it is now.
          Last edited by mathias; 15 Jan 2012, 15:11.

          Comment


            #6
            OK, i'm going to go out on a limb here and say that something is not working as expected. (well at least not as i expected :) )

            What i'm trying to achieve, as per what i've described above, is to get the d*** CSV export to format correctly.

            After above discussions, ive given up on other options and have resorted to the "expand" option, i.e. by manually opening all nodes, i hope to get all rows formatted as i'd wish.


            However, to aid the user, i've tried to do the following:

            1. check which nodes are open, put them in an array
            2. expand all
            3. export
            4. close the nodes that were open previously back up, so that the GUI looks the same to the User after the export.


            This is the code i execute when i click on my "export"-icon (taken away some unimportant stuff):
            Code:
            Tree tree = reportGrid.getGroupTree();
            TreeNode[] allNodes = (tree!=null ? tree.getChildren(tree.getRoot()) : null);
            if (tree != null && allNodes != null && allNodes.length > 0) {        
                TreeNode[] openNodes = tree.getOpenList(tree.getRoot());
                boolean[] isNodeClosed = new boolean[openNodes.length];
                for (int i = 0;i< openNodes.length;i++) {
                    TreeNode openNode = openNodes[i];
                    isNodeClosed[i] = !tree.isOpen(openNode);
                    System.out.println("closing node i");
                    //tree.closeFolder(opennode);
                }
                tree.closeAll();
                tree.openAll();
                reportGrid.exportClientData(dsRequestProperties);
            
                //THIS CAUSES FORMATTING OF CELLS TO HALT MIDWAY THROUGH!
                for (int i = 0;i< openNodes.length;i++) {
                    if(isNodeClosed[i]){
                        tree.closeFolder(openNodes[i]);
                    }
                }
            
            } else {
                SC.say("no data.");
            }
            This does not work, and it seems to be because the code *does not wait* for stuff to complete to complete.

            Nothing blocks after openAll(), the code continues right away. When exportclientdata() is called, it starts formatting rows, but at some point the export seems to spawn off into another thread, so the execution of my method continues.
            So it comes down to where i close the nodes, and when that happens, the formatting halts, without all rows getting the formatcell-call.

            If i comment out the for loops that closes the previously open nodes back up, all rows get formatted.

            I could have waited with the closing until exportclientdata is complete if there was a callback somewhere but alas.


            This seems really funky to a java coder like me, and i havent found anything in the docs to indicate that the exportclientdata happens in a separate thread.

            What can i do? Input much appreciated, this is starting to drive me nuts.
            Last edited by mathias; 19 Jan 2012, 05:11.

            Comment


              #7
              exportClientData is an async method - pass a callback as the the 2nd parameter if you want to know when it finishes...

              Comment


                #8
                Well, i did check for some callback - as i wrote:

                Code:
                I could have waited with the closing until exportclientdata is complete if there was a callback somewhere but alas.
                I sense some sarcasm with those three dots, ;) , however...

                -There is no callback in the code i'm using, my method only takes a dsrequestproperties object.

                Your javadocs say the same:
                Code:
                	
                exportClientData(DSRequest requestProperties)
                          Exports this component's data with client-side formatters applied, so is suitable for direct display to users.
                Am i missing something here?

                Comment


                  #9
                  Not necessarily - what version are you using?

                  Comment


                    #10
                    I'm running on 2.5

                    Comment


                      #11
                      2.5 didn't support an asynchronous signature of exportClientData() - that was introduced as of 3.0.

                      There was a bug in 2.5 which was causing this behavior, and which has now been fixed. However, your version is quite old now - the later versions already have both the fix we just applied to 2.5 (which will appear in nightlies from 27/6) and the signature mentioned above (which will not appear in 2.5).

                      Comment


                        #12
                        Hello,

                        hoping for a follow up answer here!

                        Now running 4.0, looking to move some of this code. Is it still the case that you have to do this opening and closing of nodes on export to make the rows render and be included in the export? (as discussed in this thread)

                        It feels so illogical to have to do that.

                        Comment

                        Working...
                        X