On Tue, Aug 21, 2007 at 10:21:32PM +0800, Allen Guo wrote:
> Usually we display user list using grid component. It's like this
> <table t:type="Grid" source="users" row="user" rowsPerPage="12"
> pagerPosition="both">
> </table>
> 
> As shown above, the source property value is 'users' is just the user
> list may fetch from database.
> The result will display all properties of user class in table .
> Now I want to only display some of properties of user class and add some
> extra columns like delete/update action to each row.
> What should I do?

To add a column, you need to create a BeanModel. 
------------------------------------
@Inject
@Service(value = "BeanModelSource")
private BeanModelSource _beanModelSource;

@Inject
@Service(value = "ComponentResources")
private ComponentResources _componentResources;

private BeanModel _model;

public BeanModel getModel(){return _model;}


public void onActivate(){
        _model = _beanModelSource.create(YOUR_OBJECT_HERE.class, true, 
                _componentResources);
                
        _model.add("action", new NullPropertyConduit()).order(-1)
                .sortable(false);

        //You /should/ use the @NonVisual action to hide properties you
        //generally don't want displayed. On the other hand, you can
        //remove properties from the BeanModel here.
}

//Other stuff elided.
-------------------------

I have a NullPropertyConduit object that is nothing but generic responses
to all of the function calls in the PropertyConduit interface. That doesn't
matter, because instead of worrying about what the conduit is going to
pull from my bean, I provide it with a template that contains this:

-------------------------
<block t:type="Grid" source="source" row="currentRow" model="model">
        <t:parameter name="actionCell">
                <a href="#" t:type="PageLink" page="delete" 
                        t:context="currentRow.id"/>Delete</a>
        </t:parameter>
</block>
-------------------------

This isn't a drop-in and have it work example, but I think all the fundamental
things you need to do to get the find of functionality you want are 
illustrated. Good luck!

-- 
njl

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to