Aug 3, 2011 at 1:40 PM
Edited Aug 19, 2011 at 1:05 AM
As I see it, NameValueList are helper objects that shouldn't be dynamic and thus shouldn't accept parameters. If you need two ways of showing data on the same table you should have two different NVL. This way you can cache each one.
Say we are talking about the Users table and you want a NVL showing only active users and another showing all users, irrespective of their
active status. You should have two NVL:
Back to the point, CslaGenFork isn't expecting ANY parameter value on the
Criteria Properties collection. If you create your NVL using the creation gestures from
Schema Columns panel, the default behaviour as set on the
Add default Criteria to NameValueList ... option, is to create an empty
Criteria. This means a Criteria with no Criteria Properties.
NOTE - This option is on the Project Properties panel, tab
Creation and sub-tab General Defaults
The tooltip for this setting says (or should say, in fact it is misplaced)
- ReadOnly collections and Name Value lists are created with a parameterless Get Criteria;
- EditableRoot and DynamicEditableRoot collections are created with a parameterless Create and Get Criteria.
But you can still add a kind of "minor" parameter to NVL, in case you want to restrict the data in the table always the same way. Of course you could use a different stored procedure for each NVL. This is just an alternative. How do you do that?
- Edit Criteria Properties and add a property (say IsActive)
- Bind it to the database column Users.IsActive
- Fill the Parameter Value according to dta type in Property Type (in this case it should be
true for getting a list of active users or false
for obtaining a list a inactive users )
Et voilá! You can use the same Stored Procedure, but in this case the SProc is passed the
Parameter Value and returns a different result according to that value.
CGF won't check if Parameter Value is correctly filled; it just checks it is filled. If you forgot to fill it, you receive the error report above.
On NameValueList only use Criteria Properties when you need to pass the Parameter Value to the SProc. Otherwise, don't use
POST SCRIPTUM - For more demanding scenarios, you can use ReadOnlyObject/ ReadOnlyCollection, for instance when you need a tree combo box.