i have writte like this in 20.1 childViews: _.e...
# suitecommerce
g
i have writte like this in 20.1 childViews: _.extend(ItemsSearcherItemView.prototype.childViews, { 'Product.Price': function () { var self=this; var pModel=new ProductModel(); var item = pModel.get('item'); var itemId=this.model.get('internalid'); item.fetch({data{iditemId}}); console.log('item',item); return new ProductViewsPriceView({ model:item //, origin: this.inModal ? 'PDPQUICK' : 'PDPFULL' }); } }); But i dont know how to write in 20.2
s
The best practice for 20.1 and 20.2 is to use the extensibility layer to add a new child view: https://system.netsuite.com/help/helpcenter/en_US/APIs/SuiteCommerce/Extensibility/Frontend/Layout.html#addChildView
g
I have used product model in that previous version,how to use here
s
I've not tried it in this specific scenario but
contextDataRequest: ['item']
should work
In SCView you make the request in the constructor by doing this
this.contextDataRequest = ['item'];
g
I will try this one..thank you
I am getting error that is requested context data is not defined for this child view instance
Any idea
var SCView = SCViewModule.SCView; function AddChildViewToItemSearcherItemViewView(options) { SCView.call(this); this.options = options || {}; this.template = ahr_addchildviewtoitemsearcheritemview_addchildviewtoitemsearcheritemview_tpl; this.contextDataRequest = ['item']; } AddChildViewToItemSearcherItemViewView.prototype = Object.create(SCView.prototype); AddChildViewToItemSearcherItemViewView.prototype.constructor = AddChildViewToItemSearcherItemViewView; AddChildViewToItemSearcherItemViewView.prototype.getContext = function () { var itemdata = this.contextData.item && this.contextData.item(); console.log('itemdata',itemdata); this.message = this.message || 'Hello World!!' return { message: this.message } } AddChildViewToItemSearcherItemViewView.prototype.validateContextDataRequest = function() { return true; } AddChildViewToItemSearcherItemViewView.prototype.contextDataRequest = ['item']; return AddChildViewToItemSearcherItemViewView;
i have written like this..still also i can't able to get theitemdata
s
Well, I think the most likely explanation then is that contextDataRequest is not available in this view
g
Then how can get the item information ??any work around for that
s
OK, I think a bigger problem is that item searcher item cells don't have placeholders into which you add new views
g
We dont have a option to add the core modules as a dependacies right..then how to use that ??Ay suggestions?
s
No, I have no suggestions. I think that this is a significant gap
g
😐
we have done many customizations with core modules as a dependancy
s
Well, AFAIK there's currently no way to do this particularly customisation without using core modules. I have submitted an enhancement request.
g
Okay thank you
Can we write afterviewrender function in scview??
s
Maybe, I'm not tried. It's not considered part of the extensibility API
g
can we write initialize function?
var SCView = SCViewModule.SCView; function HomePageBlogView(options) { SCView.call(this,options); //this.options = options || {}; this.template = ahr_homepageblog_homepageblog_tpl; this.model=options.model; this.environment=options.environment; this.application=options.application; this.on('afterViewRender',function(){ self.mycode(); }); }
i have written like this.But my function is not triggering
s
Hey I checked into this and doing something like this on SCView should work fine:
Copy code
ExampleView.prototype.render = function () {
    SCView.prototype.render.call(this);
    // my code
}
It should have the same effect as
afterViewRender
g
Thank you steve