Announcement

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

    Export row numbers?

    I have a listgrid which I want to export to Excel. This works fine.
    But how to export the row numbers set by setShowRowNumbers(true); without doing this programatically ?

    Using smartgwt 5.0p power 27.01

    #2
    We're taking a look at this

    However, can we just clarify what exactly you're after?

    Are you saying
    - you have a grid where setShowRowNumbers(true) has been called (so row numbers are showing) and you want those numbers to be present in the export, or
    - that you have a grid where setShowRowNumbers(true) has not been called (so the row numbers are not visible), but you want them to show up in the export?


    Thanks
    Isomorphic Software

    Comment


      #3
      The first one:

      - you have a grid where setShowRowNumbers(true) has been called (so row numbers are showing) and you want those numbers to be present in the export, or

      Thanks

      Comment


        #4
        Assuming you're wanting to show the row number field, and have it show up in the export, you can achieve this by the following steps:
        - on your ListGrid, use listGrid.setRowNumberFieldProperties() to allow export of the rowNumber field (via setCanExport(true)) and, if required, use setAttribute() to set exportTitle to an appropriate title.
        - to perform the export, call exportClientData() on the ListGrid. Pass in a DSRequest configuration with the export format set to ExportFormat.XLS.

        This should get you the behavior you are after.
        Please let us know if this doesn't work for you or doesn't meet your needs.

        One note: We are seeing some issues doing this with ExportFormat.OOXML which we are currently investigating.

        Regards
        Isomorphic Software

        Comment


          #5
          This is not working with exportData() instead of exportClientData().

          Comment


            #6
            exportClientData() is also not working: I am getting an empty column with title: $74y

            The code:
            Code:
            ListGridField counterField = new ListGridField();
            		counterField.setCanExport(true);
            		counterField.setAttribute("exportTitle", "");
            		setRowNumberFieldProperties(counterField);
            But even if exportClientData() worked, I still need exportData(), since I do not only want to export the client data.

            Comment


              #7
              Hi edulid,

              would a DS-field with a customSelectExpression set to "ROWNUM" (or it's SQLServer equivalent) work?

              I think it is not possible with exportData() otherwise.

              Best regards,
              Blama

              Comment


                #8
                I will try your suggestion, thanks.

                @Isomorphic could you please confirm that this is not possible otherwise than using t-sql code?
                If yes, why isn't this possible? I have the listGrid with the rowNumbers (setShowRowNumbers(true)) , which works for more than 75 records, thus for listGrid scrolling. Why isn't it possible to export that data that we already have?

                Comment


                  #9
                  Take a look at the docs for exportData() vs exportClientData().

                  exportData() goes to the server and brings nothing from the in-browser grid definition except criteria and sort direction, so the idea of a special field that holds a row number does not exist on the server. For exportData(), any way of having a server-side field definition where your server code returns row numbers will cause a row number field to appear in the export. The implementation doesn't have to be a SQL expression.

                  exportClientData() is working for you with the sole exception of the field name being obfuscated to $74y, which happens because the row number field is normally an internal detail of grid rendering - we've never seen anyone want to export it. If you had your own row number field however, that would export fine.

                  Comment


                    #10
                    There is no rownum equivalent in mssql.

                    But I still think the row count information is already available.
                    setShowRowNumbers(true); correctly displays the row number of the rows, even if there are more than 75 records, i.e. this works on the server-side. If I scroll down, I have 1000, 1001, etc. So this works already.
                    I just need THIS SAME INFORMATION THAT WE ALREADY HAVE to be exported to excel. Why allow this on a listgrid, but do not allow this in an export from this same grid?

                    Comment


                      #11
                      Hi edulid,

                      I'm pretty sure the fact that the rownumbers are known when scrolling mid-dataset is related to the ListGrid already knowing the total number of rows, see progressiveLoading. But this of course has nothing to do with your request to export the numbers as well.

                      Best regards,
                      Blama

                      Comment


                        #12
                        It seems like we already answered this question?

                        With exportData(), the server doesn't have any of the data generated client-side, including row numbers. You can add server-side code to generate row number data, of course (in SQL or not).

                        With exportClientData(), we simply didn't anticipate someone wanting to export the built-in rowNumber field (and we're planning to make this possible). But again here, you can add your own (trivial) implementation of a row number field, and that exports fine.

                        Comment

                        Working...
                        X