filtered Datagrid in pdf format

Njiua

New member
Joined
Oct 4, 2021
Messages
2
Programming Experience
Beginner
Hey Guys,

For a database project I'm planning to make a datagrid filled with information. After the datagrid is filled in I'd like to filter it and export it to a PDF.

By now I've got a working datagrid, a button which allows me to manually add new rows and an export button which export the datagrid to PDF.
(I'll upload my code when I get home)

What I'd like to do is put a dropdown menu within the datagrid to sort the data, per example:

--------------------------------------------------------------------------------------------------------------------------------------------------------------
I've got a few LP's, CD's, DVD's and games. In my dropdown I'm able to choose what media the file uses.
see the image

1633347187624.png


the goal is that if I export my data right now, that instead of one datagrid with all data my PDF file contents 3 grids. one per media

I was thinking to do something as:

if (media == LP)
export datagrid1 blablabla

if (media == game)
export datagrid2 underneath datagrid 1

etc etc
--------------------------------------------------------------------------------------------------------------------------------------------------------------

Is there someone who might be able to give me a push in the right direction?
I'd love to be able to finish this project :)

kind regards!
 
This is tangential to your project, but why is it the job of your datagrid to export to PDF? Yes, I know that back in the 80's and 90's Windows Controls and UI Widgets were all the craze and they were big monolithic constructions that did everything including making you breakfast in the morning. Those days are gone. People have learned to make UI components do just one thing very well and not add any extra bloat. (I think the only UI component that still does every thing is just Crystal Reports due to backward compatibility reasons.)

Anyway, if your data is actually stored in a collection behind your DataGrid like a proper modern component where the (data) Model is separate from the (UI) View., then simply applying the [il]GroupBy()[/il] LINQ extension method on the the collection will let you get the rows grouped by media. You can then iterate over the groups of rows and send them to your PDF rendering code to have the rows added to the PDF.

Now on the other hand, if you are storing your data in the DataGrid UI like an 80's Windows control, then you are in for more work because now you have to implement the grouping yourself.
 
Anyway, if your data is actually stored in a collection behind your DataGrid like a proper modern component where the (data) Model is separate from the (UI) View., then simply applying the [il]GroupBy()[/il] LINQ extension method on the the collection will let you get the rows grouped by media. You can then iterate over the groups of rows and send them to your PDF rendering code to have the rows added to the PDF.

The idea with media is an example, the reason that I'd like it to be printed in an PDF file is because all of the value's noted in the database will be mailed to clients afterwards. since a pdf is more professional compared to an excel or a word document.

I don't really mind how the data is saved, I just need to be able to open the program, fill in some base details in a first activity, then got to a second activity to input the data for the datagrid (or so). Export the file and done... So while I'm recording the data it'll be necessary to be able to adjust the data on the go. In my mind a datagrid is an easy way to have all the data visible before exporting it.

I'll look into the LINQ extionsion as well. this might do the trick, or atleast help me in discovering how solve this challenge.
 
Back
Top Bottom