Data Selection from AG Grid Column

Hi jinnyzor,
I have similar topic.
I have column in my grid that gathers some information from other columns and puts them together. My collegue needs to copy only this column. is there any easy solution for selecting column ?

Hello @acidkans,

Do you mean your colleague will always select the data from this column?

I dont understand why you would need to select the whole column if it is always going to be the same?

You could use text selection, though this doesnt work well with spanning rows.

Is it possible for you to provide an MRE for this use-case?

my idea is to use filtering and copy whole column with filtered data…so it’s not going to be the same whole time…
the column I want to copy data from gets names, values and concatenate them.
Something like: " task accepted by “Frank” on 02.02.2024" where name and date is from other columns…
I use this column as description of invoices…

sorry what is MRE?

Sure, check out this explanation:

below definition of this column. besides there are some Polish and German words…
this column gathers all data needed for invoice description…

{'headerName': 'INVOICE DESCRIPTION',"wraptext":True,"filterParams":{"excelMode": "windows"},"autoHeight":True,
          'valueGetter':{"function": "params.node.rowPinned != 'bottom' ? 'Prace instalacyjne w tygodniu ' + +' na stacji '+ +', "   "zgodnie z zamĂłwieniem ' + ' / Installation Arbeiten am ' + + ', gemacht in KW '+ + '; gemaĂź der Bestellung ' + '; akzeptiert am ' + + ' von ' + : null;"}}]

If, you want to use AG Grid Enterprise, :money_mouth_face:, then you can use range selection and copy the data from there.

If, you dont want to use Enterprise, then you will need to be a little more creative in how you do it.

You could potentially create your own header and have a button that would loop through the filtered data using the api, building the copied column and adding it to string of text, then sending this string of text to the navigator clipboard.

1 Like

Another solution would be to use a regular button and update a dcc.Clipboard with the virtualRowData in a callback.

For this to work, you would need to update the data in the valueGetter so it includes the invoice description


Hi AnnMarie, jinnyzor
thanks for hints. for me updating valueGetter was too complicated …
I found different solution

# ------------------------------------- copying  invoice_description to excel
    Output('download-local-to-xlsx', "data", allow_duplicate=True),

    Input("btn-hua-to-excel", "n_clicks"),
    State("grid-fakturowanie", "columnState"),
    State("grid-fakturowanie", "virtualRowData"),
def export_huawei_to_excel(n_click, columnState, virtualRowData):
    df_selected_columns = pd.DataFrame(virtualRowData)
    df_selected_columns['invoice_description']= df_selected_columns.apply(lambda row: f"Prace instalacyjne w tygodniu {row['week']} na lokalizacji {row['site']}",axis=1)
    df_selected_columns_export = df_selected_columns[['site','invoice_value','invoice_description']]

    return dcc.send_data_frame(df_selected_columns_export.to_excel, 'export_fakturowanie.xlsx', index=False)
#  ------------------------------------------------------------------------------------------------------------------

it works perfectly

1 Like