Filtering dataset

edited February 2013 in FastReport 4.0
It is possible to filter the records in a dataset directly in the process of designing without creating a new dataset ad hoc!
In practice I have a dataset (TfrxUserDataSet) that contains all the records, I would like to use it directly within differents databands, but filtering it, to display in a databand records of a type and in another databand records of another type, and then not print records that do not belong neither to the first nor the second type!
It is possible to perform a procedure of this kind?

Comments

  • edited 1:43AM
    lorenzob wrote: »
    It is possible to filter the records in a dataset directly in the process of designing without creating a new dataset ad hoc!
    In practice I have a dataset that contains all the records, I would like to use it directly within differents databands, but filtering it, to display in a databand records of a type and in another databand records of another type, and then not print records that do not belong neither to the first nor the second type!
    It is possible to perform a procedure of this kind?
    Could you give a bit more details about your issue:
    - What kind of dataset do you have - table or query?
    - Is it a problem for you to create some more queries with a specific where phrase?
    - What kind of databands are you going to use? Will they all be MasterData or Footer / Group Header/Footer?

    TDataSet has two properties: Filter and Filtered. The first is a string, the second is Boolean. You may use it for testing.
    But (probably) FastReport may use that filter for filtering records itself and it may take time.
    I suggest you to use queries as they are faster and are managed by database engine.

    Regards
    Mick

  • edited February 2013
    Mick.pl wrote: »
    Mick.pl wrote: »
    It is possible to filter the records in a dataset directly in the process of designing without creating a new dataset ad hoc!
    In practice I have a dataset that contains all the records, I would like to use it directly within differents databands, but filtering it, to display in a databand records of a type and in another databand records of another type, and then not print records that do not belong neither to the first nor the second type!
    It is possible to perform a procedure of this kind?
    Could you give a bit more details about your issue:
    - What kind of dataset do you have - table or query?
    - Is it a problem for you to create some more queries with a specific where phrase?
    - What kind of databands are you going to use? Will they all be MasterData or Footer / Group Header/Footer?

    TDataSet has two properties: Filter and Filtered. The first is a string, the second is Boolean. You may use it for testing.
    But (probably) FastReport may use that filter for filtering records itself and it may take time.
    I suggest you to use queries as they are faster and are managed by database engine.

    Regards
    Mick

    The problem is that I don't think in my case it is possible to use a query, as my dataset is of type TfrxUserDataSet, and I haven't a database ADO / DBX like support!
    I have to allow some customers to run trivial reports, data are coming from a single table, but they should be filtered according to a specific field.
    These customers do not know anything about query/sql, and I wanted to find a simple way, that would allow them to enter text in a field, just the name of the type of data they want to filter and get the report relative!
    Something like the field "break on" of the Group header, that allows you to specify a field or expression to generate groups!

    thanks
    Lorenzo
  • edited 1:43AM
    wrote:
    The problem is that I don't think in my case it is possible to use a query, as my dataset is of type TfrxUserDataSet, and I haven't a database ADO / DBX like support!
    I have to allow some customers to run trivial reports, data are coming from a single table, but they should be filtered according to a specific field.
    These customers do not know anything about query/sql, and I wanted to find a simple way, that would allow them to enter text in a field, just the name of the type of data they want to filter and get the report relative!
    Something like the field "break on" of the Group header, that allows you to specify a field or expression to generate groups!
    ...
    After looking at Classes I can't see any natural methods of filtering for TfrxUserDataSet nor TfrxDataSet [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> IMO there are only two ways to do what you need. First one is based on FR script in OnBeforePrint event for MasterData - that script should verify value of a certain field and make other bands visible or not. Or something similar but still based on manipulating bands and FR script. The second (I like it MUCH more) needs an access to any Database you can have in your application controled by[/img]TfrxCustomQuery.
    Shortly - you do that in two passes. First you read all records from TfrxUserDataSet (using Open, Next, Eof, Value properties) and insert them into a table you created in your Database. And having the table and ADO/DBX query you can do whatever you wish [img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> If any of the above seems interesting to you then we can continue. But notice - I'm fond of databases[/img][img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> BTW could you say a word about that TfrxUserDataSet - what kind of data is it? Regards Mick[/img]

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.