Reusing views

6 views
Skip to first unread message

murrayh...@gmail.com

unread,
Jul 17, 2015, 10:31:51 PM7/17/15
to gl...@googlegroups.com
Hello again.

I have a view like this:

glu.defView('App.glu.OrganisationList', {
name: 'OrganisationList',
xtype: 'grid',
columns: [{
header: '~~orgid~~',
width: 50,
dataIndex: 'orgid'
}, {
header: '~~orgtype~~',
width: 40,
dataIndex: 'orgtype'
},
// etc, more columns
],
// etc, other config
});

And I would like to reuse that view on another viewModel. If I understand the example in the Glu guide correctly:

glu.defView('helloworld.main',{
title : 'My top level view',
layout:'hbox',
items : [{html:'a panel declared inline'}, { xtype : 'aboutCompany'}]
});
glu.defView('helloworld.aboutCompany',{
title : 'Imagine a bunch of widgets about us'
});

it seems that I could do this:

glu.defView('App.glu.UserOrgList', {

name: 'UserOrgList',

// Trying to reuse the OrganisationList view.
xtype: 'OrganisationList'

// Also didnt work:
// xtype : 'App.glu.OrganisationList'

// I tried this too:
//extend : 'App.glu.OrganisationList'

});

So, what is the correct Glu way to 'extend' a view so I can reuse it and override some of the config?

Thanks again,
Murray

Josh VanderLinden

unread,
Jul 17, 2015, 11:08:38 PM7/17/15
to gl...@googlegroups.com

murrayh...@gmail.com

unread,
Jul 19, 2015, 3:08:40 AM7/19/15
to gl...@googlegroups.com
Yep! That's it! Works great.

So, have you used this pattern for anything?

glu.defView('helloworld.main',{
title : 'My top level view',
layout:'hbox',
items : [{html:'a panel declared inline'}, { xtype : 'aboutCompany'}]
});
glu.defView('helloworld.aboutCompany',{
title : 'Imagine a bunch of widgets about us'
});


Thanks,
Murray

Ryan Smith

unread,
Jul 20, 2015, 12:22:44 PM7/20/15
to gl...@googlegroups.com
I have used this pattern on a FormBuilder long ago where the user was able to create forms by dragging and dropping components onto the form.  This worked perfectly because I could then easily just add the viewmodel to the list of controls and glujs would render the view for me and I didn't have to worry about configuration or anything like that... everything was just magically handled for me :).

-Ryan

--
You received this message because you are subscribed to the Google Groups "GluJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glujs+un...@googlegroups.com.
To post to this group, send email to gl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glujs/2d988704-c1e2-4b3c-a74b-4db863d046e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages