Skip to main content

Posts

NRapid, customizing autocompletes take 2

In a previous post I‘ve shown you how to add columns to the autocomplete control. In that post, I used the NRapid's internal API which is a bit noisy from a syntactic perspective. In this post, I’ll show you how to do the same thing we did before, but using a cleaner syntax.  Some syntactic sugars I’ve added to the report class. (Internally it works the same way that the previous example) And as you can see, the end result is the same. On the next post, how to work with autocompletes and cascade filters. You can get the source code of NRapid from  here And the sample app from  here The Northwind database is available from download at  http://www.microsoft.com/en-us/download/details.aspx?id=23654

NRapid, customizing the autocomplete control

A while ago I got a question about the autocomplete control, “it’s possible to use records coming from different tables as an autocomplete data source?” The answer is yes, It’s possible, but requires a bit of configuration. The use case was simple, but does not fit into the NRapid default feature set. By default, autocompletes work with a data source that contains just two columns, the record id and a description field (which is used to filter records). Those two columns must come from the same table . In this case, the user wants to see additional columns coming from different tables, so the solution requires a bit of hacking. I’ll show you how to do this, by combining two tables, products and categories. Basically I’ll add the category name (from Categories) to the products autocomplete data source (which by default just has the product id and the product name, both coming from the products table). To make this thing work, we need to use the  customization f...

Working with autocompletes in NRapid

One of the main goals behind relational databases design is reduce/eliminate the amount of duplicated data. In order to do that, they split the data into multiple tables and relate them by FK. While this works really well in database terms, they don’t when it comes to searching or loading data (In highly normalized database we usually need a lot of JOINs) Continuing with an example that we were working on previous posts ( products by category ) we can see this design lines in action.  The goal of our report is allow the users to select a category, and based on that category, fetch the corresponding list of products. The problem is, if we look at the products table, the product's category is and ID (numeric), which is hard to remember and does not make any sense on his own . In this kind of scenarios, we can use the autocomplete control . This control will allows to the user to filter by description (category name) or any field that make sense to him/her and pass to ...

Working with combos in NRapid

I think that working with combos is the most complex thing that you can do with NRapid, they are hard to configure and requires a lot of plumbing code, but they are really handy when you have to work with fixed sets of options. This time I’m going to build a report that shows some employees info. The report’s dialog will allows us to filter that info based on the employees city and get smaller result sets. Cities are a fixed set of data(at least in Northwind) so combos will be a nice choice. In order to get a combo, we need to add to properties to the nested dialog. Those properties will work together to make selection works. The code may look something like this: Notice that City is annotated with the ViewIgnore attribute, this is the way to tell to engine "do not create a control for this property" . And Cities is annotated with the DispalyOptionsFor attribute pointing to City, this means that the selected option in the combo will be used to set the valu...

Working with dialogs in NRapid

In this post I’ll cover the basic usage of dialogs in NRapid, how do they work and what kinds of controls do we have available. As we already saw, to create a dialog we have to add a nested class named "Dialog" inside a report. In order to add controls, we need to define properties in that class, and based on the properties type, the report engine will create and add the controls to the dialog. This mechanism is pretty much based on conventions, but we have some attributes to annotate the properties and modify the default behavior. This post is on basic usage of dialogs, so combos and autocompletes are off the table, because they requires a bit more of configuration. And then when we run the report we get this As you can see in the output dialog, one of the engine conventions is “first defined, first served” , but sometimes this is not the desired behavior or you maybe want to add columns or change the text on the labels or stuff like that. To do that y...

How to add footers to NRapid reports

Grouping data it's really cool feature, that help us out to provide some sort of data visualization enhancement, it makes the report easy on the eyes and allows to the users  to figure out what’s going on without going into much detail. But usually, that it’s not enough, along with grouping, we'll also need to provide some additional info, such as the day takes, month takes, etc, etc… to complement the grouping functionality and make the report really useful. This time I going to work with products and categories, I’m going to build a report to show units in stock for each product on each category in our database and add a footer to show the units per category (this is the sum of the units per product for a given category). In a previous post I’ve shown you how to create reports and group data, so I’ll going to skip those steps here and concentrate in the footer section. The code you will see below must be place inside the configure report method (also covered in previous...

Linked reports with NRapid

Being able to link reports it’s really handy feature that usually the end users of our system will love it. For instance, you can create a report that that displays order’s headers and when the users click on the order’s id, he/she can see a child report with the order’s detail. In this case I’m going to work with categories and products but the technique can be applied to any master-detail scenario. First of all we need to create a report that shows the list of categories (we already did that in a previous post, so I’m not going into details here) and then somehow link this report with a report that show a list products for a specific category. This might sound complex, but with NRapid is pretty straightforwa rd and only will take you just a line of code inside the configure method: *There’s also a cool feature inside NRapid reports that allows us to run arbitrary c# code when the user clicks a link but this feature deserves his own post ;) What does ...