jQWidgets Forums

jQuery UI Widgets Forums Grid Restrict getrows result to only include displayed columns

This topic contains 4 replies, has 2 voices, and was last updated by  Duncan 6 years, 6 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author

  • Duncan
    Participant

    Because of the issues with the Excel export function, I’m trying to get hold of the data that I want to export so that I can do it myself. I’m using the getrows function, which give me all the rows I need, but I have a couple of issues.

    1. The column headers are the original headers in the data – I need the headers that I’m displaying in the grid.
    2. It includes all columns, even the hidden ones.

    Is there an easy way for me to resolve these, or will I have to code it all manually?

    I’m using the Angular version of the grid.


    Peter Stoev
    Keymaster

    Hi Duncan,

    In case you do not wish to export a particular column, you can use the column’s exportable property and set it to false.
    Regarding the getrows, it returns the grid’s data source and does not take into account whether a column is visible or not. You can loop through the returned array and filter it and if a column is hidden, do not include it in the resulting array.

    Regards,
    Peter


    Duncan
    Participant

    Hi Peter,

    I’ve tried setting the columns’ exportable property to false wherever their hide property is true, but unfortunately it’s still exporting everything.

    As for looping through the returned array, I take it I would need to iterate through the columns using getcolumnat, use that to interrogate the hidden property, and then use that to remove columns from a copy of getrows?

    In addition, is there a simple way to apply the formatting of each column to my data so that my Excel file will be formatted the same way?

    Thanks,


    Duncan


    Peter Stoev
    Keymaster

    Hi Duncan,

    Please, look at this example – http://jsfiddle.net/2Lkx087o/ about using exportable property of our Grid columns. First and Second columns are not exported to Excel.

    We do not have bullt in code which limits the results of getrows method.

    To format data in the Grid, use the column’s cellsformat property. The same format setting is taken into account when you export the Grid. In the sample, you will see that the numeric columns formatting in the Web Page matches the numeric columns formatting in Excel.

    Regards,
    Peter


    Duncan
    Participant

    Hi Peter,

    Thanks for the extra information. Unfortunately I’m not using the built-in export function (because of the “this is an incorrect file type” message that it creates), so I’m having to do it manually using XLSX.utils.

    Thanks,


    Duncan

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.