Developer Forums Previous Topic Next Topic
Title:
Better looking Many-to-Many check box items

Content:
When you have a many-to-many relationship where you use the checkboxes to add items, by default, you'll see the check box to the left of the item name, but this item name is not always sufficient detail about the item to know if you want to click the check box.

One place you can quickly see this is when you click Design > Quicklaunch or when you are adding Group Menu Visibility. In this instance for menus, you may want to see the menu's icon next to the name to make it easier to know which icons you are adding.

This is the before:


And this is where we are going:


Much nicer, yeah?

So let's step through adding this icon next to the menu name...

Adding a defaulttemplate

  1. Add a column to t_tables called defaulttemplate. Make it a Multiline text edit or Text Unlimited. You'll need to rearrange your form field layout after doing this.
  2. Grant Column Level Security for the new defaulttemplate field:
  3. Clear your application cache, so the defaulttemplate field will be available: Develop > Clear Application Cache.
  4. Since t_tables has layout specified, you'll need to redesign the form field layout for t_tables, otherwise the field will look like this:
    This is what we want:
  5. Go to the Table Settings for the particular table that you want to have a nicer looking display next to the check box. In this case, the t_menus table.
  6. Enter a spiffy new template for your table. This template will now be the default template whenever items from this table are displayed using square brackets notation. For this example, I'll use this template:
Next we are going to add a field template for the name field when we are in the add many to many screen.

Adding the field template for view 25 - checkboxes

  1. Choose Design > Quicklaunch
  2. Choose Design > Field Templates
    1. Click the Add New icon

    2. Give it a name like this "tablename.name" where tablename is the many-to-many table used to manage our relationship. For this instance, we'll choose Quicklaunch.name
    3. In the columnname field enter name
    4. In the itemtemplate field enter [[left]:[_id]] You'll use this same item template regardless of the tables in question.
    5. Save the field template
Return to the many-to-many assignment page and you should see the nice template there. In this case, choose Design > Quicklaunch and you should see the icons next to the menu names.

Explanation


Here's what's going on. defaulttemplate is an as of yet undocumented feature that allows you to create special templates for items when they are referenced using this style of notation: [[TABLE_NAME]:[ID]] where TABLE_NAME is some table in your Qrimp app and ID points to a specific item in that table. Without the defaulttemplate Qrimp will just create a hyperlink to the display view (view 11) using the name field, or other defaultfield that you specify in the Table Settings.

The next step, where we add the field template for the name field, we are taking the table name specified by the left parameter in the querystring and the hidden id field Qrimp uses to know which items you are checking.

When Qrimp builds that table containing the check boxes, it replaces that generic reference to the specific item with the default template you created for the table.

If you have any questions about this, don't hesitate to ask.

replies



createdate:
12/11/2008 1:49:49 AM

createid:
pj