Hi All, How can we give different template, based ...
# suitecommerce
g
Hi All, How can we give different template, based on condition in view.js file??
v
@Geetha every View.js has a 'template' property that contains the reference for the default template of the View. You might be able to assign a different reference to that property before rendering the View (or, by changing the reference and then re-rendering the view). You'll have to load all possible templates that the View can use in the 'define' parameters, and then pass the appropriate reference to the template property of the View dynamically.
I've never tried it myself, but it might work.
g
I have tried,but it is showing error
View doesn't have error
k
@Geetha, do you have access to the SuiteCommerce Advanced source code? If so, take a look at the Facets module. The Facets.ItemCell.View displays three different templates: facets_item_cell_grid.tpl facets_item_cell_list.tpl facets_item_cell_table.tpl
@Geetha another way we’ve done this in the past is to define each template as a separate view, define all of the views in a parent view then control the display of the views using conditionals in the parent view’s template file.