Empty Product List

An error occurred while processing the template.
Error on line 64, column 5 in 254#294#1498146
DDLRecordLocalService.getRecord(recordId?number) is undefined.
It cannot be assigned to currRecord
1<script type="text/javascript"> 
2    if (!String.prototype.startsWith) { 
3      String.prototype.startsWith = function(searchString, position) { 
4        position = position || 0; 
5        return this.indexOf(searchString, position) === position; 
6      }; 
7
8</script> 
9 
10<#assign context = staticUtil["com.liferay.portal.service.ServiceContextThreadLocal"].getServiceContext()>   
11<#assign httpServletRequest = context.getRequest()> 
12 
13<#assign DDLRecordLocalService = serviceLocator.findService("com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService") /> 
14<#assign DDMStructureLocalService = serviceLocator.findService("com.liferay.portlet.dynamicdatamapping.service.DDMStructureLocalService")> 
15<#assign DDLRecordSetLocalService = serviceLocator.findService("com.liferay.portlet.dynamicdatalists.service.DDLRecordSetLocalService")> 
16<#assign DLFileEntryLocalService = serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService") /> 
17<#assign LayoutLocalService = serviceLocator.findService("com.liferay.portal.service.LayoutLocalService") /> 
18 
19<#assign currentURL = portalUtil.getCurrentCompleteURL(request) />   
20<#assign recordId = (httpServletRequest.getParameter('sharpProductRecordId')?html)!''> 
21<#assign categoryName = (httpServletRequest.getParameter('sharpCategory')?html)!''> 
22<#assign locale = localeUtil.getDefault() /> 
23 
24<#-- Get the recordSet based on the url parameter (or use the selected list if the url parameter is not specified) --> 
25<#assign recordSet = DDLRecordSetLocalService.getDDLRecordSet(reserved_record_set_id)> 
26<#if categoryName?has_content> 
27    <#assign recordSets = DDLRecordSetLocalService.getRecordSets(groupId)> 
28    <#list recordSets as currRecordSet> 
29        <#if currRecordSet.getName(localeUtil.getDefault()) == categoryName> 
30            <#assign recordSet = currRecordSet> 
31            <#break> 
32        </#if> 
33    </#list> 
34</#if> 
35 
36<#-- Get the field names that existed for every products from portal properties --> 
37<#assign productNumberFieldName = propsUtil.get('ddl.field.product.number')> 
38<#assign productDescriptionFieldName = propsUtil.get('ddl.field.product.description')> 
39<#assign productImageFieldName = propsUtil.get('ddl.field.product.image')> 
40<#assign productDocumentationFieldName = 'Documents'> 
41<#assign productApplicationsFieldName = propsUtil.get('ddl.field.product.applications')> 
42 
43<#assign fieldNotDisplayInCatPage = [productDescriptionFieldName, productImageFieldName, productDocumentationFieldName, productApplicationsFieldName] > 
44<#assign fieldNotSpecification = [productNumberFieldName, productDescriptionFieldName, productImageFieldName, productDocumentationFieldName, productApplicationsFieldName] > 
45 
46<#assign currStructure = recordSet.getDDMStructure() > 
47<#assign fieldNames = currStructure.getFieldNames() > 
48<#assign displayInCatPageFieldNames = [] > 
49<#assign specificationFieldNames = [] > 
50 
51<#-- Populate list of field names displayed on category page and list of field names under specification --> 
52<#list fieldNames as fieldName> 
53    <#if !currStructure.isFieldPrivate(fieldName) && !fieldNotDisplayInCatPage?seq_contains(fieldName)> 
54        <#assign displayInCatPageFieldNames = displayInCatPageFieldNames + [fieldName] > 
55    </#if> 
56    <#if !currStructure.isFieldPrivate(fieldName) && !fieldNotSpecification?seq_contains(fieldName)> 
57        <#assign specificationFieldNames = specificationFieldNames + [fieldName] > 
58    </#if> 
59</#list> 
60 
61 
62<#if recordId?has_content> 
63    <#-- individual product page --> 
64    <#assign currRecord = DDLRecordLocalService.getRecord(recordId?number) /> 
65    <#assign currRecordFields = currRecord.getFields() > 
66     
67    <div class="row-fluid"> 
68        <div class="span9"> 
69            <#assign prodNumberField = currRecordFields.get(productNumberFieldName)!currRecordFields.get("Part_no")> 
70            <#assign prodDescriptionField = currRecordFields.get(productDescriptionFieldName)!> 
71            <#if prodNumberField?has_content> 
72                <#assign productNumberNoLocale = prodNumberField.getValue()!> 
73 
74                <h1>${prodNumberField.getValue()}</h1> 
75            </#if> 
76            <#if prodDescriptionField?has_content> 
77                <p>${prodDescriptionField.getValue()!""}</p> 
78            </#if> 
79        </div> 
80        <#-- Populate call to action button logic on product detail pages --> 
81        <div class="span3 side-buttons"> 
82            <a href="#" class="backToCategory">Back to ${recordSet.getName(locale)} ></a> 
83            <#if !productNumberNoLocale??> 
84               <#assign productNumberNoLocale = "TEST"> 
85            </#if> 
86			<#if currentURL?lower_case?contains("discontinued%20industrial")> 
87            <a href="/contact" class="btn btn-primary">Contact a Rep ></a> 
88			<a href="/sharp-industrial-application-ia-lcds" class="btn btn-primary">IA Advantage ></a> 
89			<#elseif currentURL?lower_case?contains("discontinued%20memory")> 
90            <a href="/contact" class="btn btn-primary">Contact a Rep ></a> 
91			<a href="/sharp-memory-lcd-technology" class="btn btn-primary">Product Technology ></a> 
92            <#elseif currentURL?lower_case?contains("industrial")> 
93                <a href="/where-to-buy?buyNow=true" class="btn btn-primary buyIndProductBtn" data-product-number="${productNumberNoLocale}">Buy Now ></a> 
94                <a href="/contact" class="btn btn-primary">Contact a Rep ></a> 
95                <a href="/sharp-industrial-application-ia-lcds" class="btn btn-primary">IA Advantage ></a> 
96          	<#elseif currentURL?lower_case?contains("memory")> 
97                <a href="/contact" class="btn btn-primary">Contact a Rep ></a> 
98                <a href="/where-to-buy?buyNow=true" class="btn btn-primary buyIndProductBtn" data-product-number="${productNumberNoLocale}">Buy Now ></a> 
99                <a href="/sharp-memory-lcd-technology" class="btn btn-primary">Product Technology ></a> 
100            <#elseif  currentURL?lower_case?contains("signage")> 
101                <a href="/contact" class="btn btn-primary">Contact a Rep ></a> 
102                <#--<a href="/e-signage-modules" class="btn btn-primary">E-Signage Technology ></a>--> 
103            <#elseif currentURL?lower_case?contains("ccd")> 
104                <a href="mailto:customcamera@sharpsec.com?subject=New%20Custom%20Camera%20inquiry&amp;body=I%20am%20interested%20in%20discussing%20CCD%20product%20design%20for%20a%20CCD%20camera%20module%20project.%0A%0AMy%20name%20is%3A%0AMy%20contact%20information%20is%3A" class="btn btn-primary">Contact Sharp Microelectronics of the Americas ></a> 
105                <a href="/ccdii-technology" class="btn btn-primary">CCD II Technology ></a> 
106            <#elseif currentURL?lower_case?contains("cmos")> 
107                <a href="mailto:customcamera@sharpsec.com?subject=New%20Custom%20Camera%20inquiry&amp;body=I%20am%20interested%20in%20discussing%20CMOS%20design%20for%20a%20custom%20camera%20module%20for%20my%20imaging%20project.%0A%0AMy%20name%20is%3A%0AMy%20contact%20information%20is%3A" class="btn btn-primary">Contact Sharp Microelectronics of the Americas ></a> 
108             </#if> 
109        </div> 
110    </div> 
111    <div class="row-fluid product-information"> 
112        <div class="span8"> 
113        <div class="prodDocumentation"> 
114                <table> 
115                    <thead> 
116                        <tr class=""> 
117                            <th colspan="2"> 
118                                <h3> 
119                                    <span>Documentation</span> 
120                                    <i class="icon icon-angle-down"></i> 
121                                </h3> 
122                            </th> 
123                        </tr> 
124                    </thead> 
125                </table> 
126                <div class="tableWrap"> 
127                    <table> 
128                        <tbody> 
129                            <#assign prodDocumentationField = currRecordFields.get(productDocumentationFieldName)!> 
130                            <#assign prodDocumentationFieldValues = currRecord.getFieldValues(productDocumentationFieldName,locale)!> 
131         
132                            <#if prodDocumentationField?has_content> 
133                                <#list prodDocumentationFieldValues as prodDocumentationFieldValue> 
134                                    <#if prodDocumentationFieldValue?? && prodDocumentationFieldValue?has_content> 
135                                        <#assign prodDocumentationFieldValueObj = prodDocumentationFieldValue?eval> 
136                                        <#assign prodDocumentationFieldValueUuid = prodDocumentationFieldValueObj.uuid?string> 
137                                        <#assign prodDocumentationFieldValueGroupId = prodDocumentationFieldValueObj.groupId?number> 
138                                        <#assign currDLFileEntry = DLFileEntryLocalService.getDLFileEntryByUuidAndGroupId(prodDocumentationFieldValueUuid, prodDocumentationFieldValueGroupId)!> 
139                                        <#if currDLFileEntry?has_content> 
140                                            <tr> 
141                                                <td> 
142                                                    <#attempt> 
143                                                        <a href='${ddmUtil.getDisplayFieldValue(themeDisplay, prodDocumentationFieldValue, prodDocumentationField.getType())}' target='_blank'> 
144                                                        ${currDLFileEntry.getTitle()} 
145                                                    </a> 
146                                                    <#recover> 
147                                                        <div class="debug" data-errorLineNumber="118"></div> 
148                                                    </#attempt> 
149                                                </td> 
150                                                <td> 
151                                                    ${currDLFileEntry.getMimeType()} 
152                                                </td> 
153                                            </tr> 
154                                        </#if> 
155                                    </#if> 
156                                </#list> 
157                            </#if> 
158                        </tbody> 
159                    </table> 
160                </div> 
161            </div> 
162 
163            <div class="prodSpecifications"> 
164                <table> 
165                    <thead> 
166                        <tr class=""> 
167                            <th colspan="2"> 
168                                <h3> 
169                                    <span>Specifications</span> 
170                                    <i class="icon icon-angle-down"></i> 
171                                </h3> 
172                            </th> 
173                        </tr> 
174                    </thead> 
175                </table> 
176                <div class="tableWrap"> 
177                    <table> 
178                        <#list specificationFieldNames as specificationFieldName> 
179                            <tr> 
180                                <td><b>${currStructure.getFieldLabel(specificationFieldName,locale)}</b></td> 
181                                <td> 
182                                    <#assign currField = currRecordFields.get(specificationFieldName)!> 
183                                    <#assign currFieldValues = currRecord.getFieldValues(specificationFieldName,locale)!> 
184 
185                                    <#if currField?has_content && currFieldValues?has_content> 
186                                        <#assign currFieldRenderedValue = currField.getRenderedValue(locale) > 
187                                        <#assign currFieldIsRepeatable = currField.isRepeatable()> 
188                                        <#assign currFieldType = currField.getType()> 
189                                         
190                                        <#if currFieldType=='ddm-documentlibrary'> 
191                                            <#list currFieldValues as currFieldValue><#if currFieldValue?has_content><#assign currFieldValueObj = currFieldValue?eval><#assign currFieldValueUuid = currFieldValueObj.uuid?string><#assign currFieldValueGroupId = currFieldValueObj.groupId?number> 
192                                            <#attempt> 
193                                                <a href='${ddmUtil.getDisplayFieldValue(themeDisplay, currFieldValue, currFieldType)}' target='_blank'>${DLFileEntryLocalService.getDLFileEntryByUuidAndGroupId(currFieldValueUuid,currFieldValueGroupId).getTitle()}</a> 
194                                            <#recover> 
195                                                <div class="debug" data-errorLineNumber="168"></div> 
196                                            </#attempt> 
197                                             <#if currFieldValue_has_next>, </#if></#if></#list> 
198                                             
199                                        <#elseif currFieldType=='ddm-link-to-page'> 
200                                                                                        <#list currFieldValues as currFieldValue> 
201                                                <#if currFieldValue?has_content> 
202                                                    <#assign currFieldValueObj = currFieldValue?eval> 
203                                                    <#assign currFieldValueGroupId = currFieldValueObj.groupId?number> 
204                                                    <#assign currFieldValueLayoutId = currFieldValueObj.layoutId?number> 
205                                                    <#assign currFieldValuePrivateLayout = currFieldValueObj.privateLayout> 
206                                                    <#attempt> 
207                                                        <a href='${ddmUtil.getDisplayFieldValue(themeDisplay, currFieldValue, currFieldType)}' target='_blank'> 
208                                                            ${LayoutLocalService.getLayout(currFieldValueGroupId, currFieldValuePrivateLayout, currFieldValueLayoutId).getName(locale)} 
209                                                        </a> 
210                                                    <#recover> 
211                                                        <div class="debug" data-errorLineNumber="182"></div> 
212                                                    </#attempt> 
213                                                    <#if currFieldValue_has_next> 
214                                                        ,  
215                                                    </#if> 
216                                                </#if> 
217                                            </#list> 
218                                         <#elseif currFieldIsRepeatable> 
219                                          
220                                        <#else> 
221                                             
222                                            <#if currFieldRenderedValue?has_content> ${currFieldRenderedValue}</span></#if> 
223                                        </#if> 
224                                    </#if> 
225                                </td> 
226                            </tr> 
227                        </#list> 
228                    </table> 
229                </div> 
230            </div> 
231        </div> 
232        <div class="span4"> 
233            <#assign prodImageField = currRecordFields.get(productImageFieldName)!> 
234            <#assign prodImageFieldValue = currRecord.getFieldValue(productImageFieldName)!> 
235            <#if prodImageFieldValue?? && prodImageFieldValue?index_of("{") == 0 && (prodImageField.getType())?? && prodImageField?has_content && prodImageFieldValue?has_content> 
236                <div class="prodImage"> 
237                    <h3>Product Image</h3> 
238                    <#attempt> 
239                        <a href="${ddmUtil.getDisplayFieldValue(themeDisplay, prodImageFieldValue, prodImageField.getType())}"> 
240                            <img src='${ddmUtil.getDisplayFieldValue(themeDisplay, prodImageFieldValue, prodImageField.getType())}'/> 
241                        </a> 
242                    <#recover> 
243                        <div class="debug" data-errorLineNumber="214"></div> 
244                    </#attempt>  
245                </div> 
246            </#if> 
247            <#assign prodApplicationsField = currRecordFields.get(productApplicationsFieldName)!> 
248        
249            <#if prodApplicationsField?has_content> 
250                <div class="prodApplications"> 
251                    <h3>Applications:</h3> 
252                    <ul> 
253                        <#list prodApplicationsField.getRenderedValue(locale)?split(",") as x> 
254                            <li> 
255                                ${x} 
256                            </li> 
257                        </#list> 
258                    </ul> 
259                </div> 
260            </#if> 
261        </div> 
262    </div> 
263<#elseif categoryName?has_content && recordSet.getRecordSetId() != reserved_record_set_id> 
264    <#-- category page --> 
265    <div class="row-fluid"> 
266        <div class="span9"> 
267            <h1>${recordSet.getName(locale)}</h1> 
268            <div>${recordSet.getDescription(locale)}</div> 
269        </div> 
270        <#-- Populate call to action button logic on category pages --> 
271        <div class="span3 side-buttons"> 
272			<#if currentURL?lower_case?contains("discontinued%20industrial")> 
273            <a href="/contact" class="btn btn-primary">Contact a Rep ></a> 
274			<a href="/sharp-industrial-application-ia-lcds" class="btn btn-primary">IA Advantage ></a> 
275			<#elseif currentURL?lower_case?contains("discontinued%20memory")> 
276            <a href="/contact" class="btn btn-primary">Contact a Rep ></a> 
277			<a href="/sharp-memory-lcd-technology" class="btn btn-primary">Product Technology ></a> 
278			<#elseif currentURL?lower_case?contains("industrial")> 
279            <a href="/where-to-buy?buyNow=true" class="btn btn-primary">Buy Now ></a> 
280            <a href="/contact" class="btn btn-primary">Contact a Rep ></a> 
281            <a href="/sharp-industrial-application-ia-lcds" class="btn btn-primary">IA Advantage ></a> 
282			<#elseif currentURL?lower_case?contains("memory")> 
283            <a href="/contact" class="btn btn-primary">Contact a Rep ></a> 
284            <a href="/where-to-buy?buyNow=true" class="btn btn-primary">Buy Now ></a> 
285            <a href="/sharp-memory-lcd-technology" class="btn btn-primary">Product Technology ></a> 
286			<#elseif currentURL?lower_case?contains("signage")> 
287            <a href="/contact" class="btn btn-primary">Contact a Rep ></a> 
288            <#--<a href="/e-signage-modules" class="btn btn-primary">E-Signage Technology ></a>--> 
289			<#elseif currentURL?lower_case?contains("ccd")> 
290            <a class="btn btn-primary" href="mailto:customcamera@sharpsec.com?subject=New%20CCD%20Camera%20inquiry&amp;body=I%20am%20interested%20in%20discussing%20development%20of%20a%20CCD%20camera%20module%20for%20my%20imaging%20project.%0A%0AMy%20name%20is%3A%0AMy%20contact%20information%20is%3A">Contact Sharp Microelectronics of the Americas ></a> 
291            <a href="/ccdii-technology" class="btn btn-primary">CCD II Technology ></a> 
292            <#elseif currentURL?lower_case?contains("cmos")> 
293            <a class="btn btn-primary" href="mailto:customcamera@sharpsec.com?subject=New%20Custom%20Camera%20inquiry&amp;body=I%20am%20interested%20in%20discussing%20design%20for%20a%20CMOS%20camera%20module%20for%20my%20imaging%20project.%0A%0AMy%20name%20is%3A%0AMy%20contact%20information%20is%3A" target="_blank">Contact Sharp Microelectronics of the Americas ></a> 
294            </#if> 
295            <#--<div class="product-technology"> 
296                <a class="btn btn-primary">Product Technology ></a> 
297            </div>--> 
298             
299            </div> 
300        </div> 
301    </div> 
302    <div class="row-fluid fade-in"> 
303        <#assign records = recordSet.getRecords() /> 
304        <#if records?has_content> 
305            <div class="span3 refine"> 
306                <h3>Refine By</h3> 
307                <div class="dropdownContainer" id="filter-container"></div> 
308            </div> 
309            <div class="span9"> 
310                <div class="dropdownContainer fields"> 
311                    <label id="filterOptionsLabel" for="filterOptions" style="display: inline;"></label> 
312                        <h3 class="dropdownTrigger">Filter Options <i class="icon icon-cog" id="filterOptions"></i></h3>  
313                    <div class="dropdownContent" id="column-selector"> 
314                        <button name="select-all-button" id="select-all-button" class="btn btn-default">Select All</button> 
315                        <button name="deselect-all-button" id="deselect-all-button" class="btn btn-default">Deselect All</button> 
316                        <#list displayInCatPageFieldNames as displayInCatPageFieldName> 
317                            <label> 
318                                <#if displayInCatPageFieldName == productNumberFieldName> 
319                                    <input type="checkbox" value="${displayInCatPageFieldName_index}" data-field-name='${displayInCatPageFieldName}' checked disabled> 
320                                <#else> 
321                                    <input type="checkbox" value="${displayInCatPageFieldName_index}" data-field-name='${displayInCatPageFieldName}'> 
322                                </#if> 
323                                ${currStructure.getFieldLabel(displayInCatPageFieldName,locale)} 
324                            </label> 
325                        </#list> 
326                    </div> 
327                </div> 
328                <table id="productsInCat" class="display responsive nowrap"> 
329                    <thead> 
330                        <tr> 
331                            <#list displayInCatPageFieldNames as displayFieldName> 
332                                <th data-field-name='${displayFieldName}' data-field-type='${currStructure.getFieldType(displayFieldName)}'>${currStructure.getFieldLabel(displayFieldName,locale)}</th> 
333                            </#list> 
334                        </tr> 
335                    </thead> 
336                    <tbody> 
337                        <#list records as currRecord> 
338                            <tr> 
339                                <#list displayInCatPageFieldNames as displayFieldName> 
340                                    <#assign currField = currRecord.getFields().get(displayFieldName)!> 
341                                    <#assign currFieldValues = currRecord.getFieldValues(displayFieldName,locale)!> 
342 
343                                    <#if currField?has_content> 
344                                        <#assign rawData = currField.getValue()!""> 
345                                        <#if rawData?is_string> 
346                                            <td data-raw="${rawData}"> 
347                                        <#else> 
348                                            <td data-raw=""> 
349                                        </#if> 
350                                         
351                                    <#else> 
352                                        <td> 
353                                    </#if> 
354                                        <#if currField?has_content && currFieldValues?has_content> 
355                                            <#assign currFieldRenderedValue = currField.getRenderedValue(locale)!""> 
356                                            <#assign currFieldIsRepeatable = currField.isRepeatable()> 
357                                            <#assign currFieldType = currField.getType()> 
358 
359                                            <#assign displayFieldNameLowerCase = displayFieldName?lower_case> 
360                                            <#assign productNumberFieldNameLowerCase = productNumberFieldName?lower_case> 
361 
362                                            <#if displayFieldNameLowerCase == productNumberFieldNameLowerCase> 
363                                                <a class="productNumber" data-product-record-id='${currRecord.getRecordId()?string}' href="#"> 
364                                                    <#if currFieldRenderedValue?has_content> 
365                                                       ${currFieldRenderedValue} 
366                                                    </#if> 
367                                                </a> 
368                                                 
369                                            <#elseif currFieldType=='ddm-documentlibrary'> 
370                                                <#list currFieldValues as currFieldValue> 
371                                                    <#if currFieldValue?has_content> 
372                                                        <#assign currFieldValueObj = currFieldValue?eval> 
373                                                        <#assign currFieldValueUuid = currFieldValueObj.uuid?string> 
374                                                        <#assign currFieldValueGroupId = currFieldValueObj.groupId?number> 
375                                                        <#attempt> 
376                                                            <a href='${ddmUtil.getDisplayFieldValue(themeDisplay, currFieldValue, currFieldType)}' target='_blank'>${DLFileEntryLocalService.getDLFileEntryByUuidAndGroupId(currFieldValueUuid,currFieldValueGroupId).getTitle()}</a> 
377                                                        <#recover> 
378                                                            <div class="debug" data-errorLineNumber="333"></div> 
379                                                        </#attempt>  
380                                                        <#if currFieldValue_has_next>,</#if> 
381                                                    </#if> 
382                                                </#list> 
383                                                 
384                                            <#elseif currFieldType=='ddm-link-to-page'> 
385                                                <#list currFieldValues as currFieldValue><#if currFieldValue?has_content><#assign currFieldValueObj = currFieldValue?eval><#assign currFieldValueGroupId = currFieldValueObj.groupId?number><#assign currFieldValueLayoutId = currFieldValueObj.layoutId?number><#assign currFieldValuePrivateLayout = currFieldValueObj.privateLayout> 
386                                                <#attempt> 
387                                                    <a href='${ddmUtil.getDisplayFieldValue(themeDisplay, currFieldValue, currFieldType)}' target='_blank'>${LayoutLocalService.getLayout(currFieldValueGroupId, currFieldValuePrivateLayout, currFieldValueLayoutId).getName(locale)}</a> 
388                                                <#recover> 
389                                                   <div class="debug" data-errorLineNumber="344"></div> 
390                                                </#attempt> 
391                                                 <#if currFieldValue_has_next>, </#if></#if></#list> 
392 
393                                            <#else> 
394                                                <#if currFieldRenderedValue?has_content> 
395                                                    ${currFieldRenderedValue} 
396                                                </#if> 
397                                            </#if> 
398                                        </#if> 
399                                    </td> 
400                                </#list> 
401                            </tr> 
402                        </#list> 
403                    </tbody> 
404                </table> 
405            </div> 
406        </#if> 
407    </div> 
408<#else> 
409    <h1 style="margin-bottom:15px;">No Data Found</h1> 
410    <#--<span>Please select a category with a matching dynamic data list</span>--> 
411</#if> 
412 
413<script> 
414    $(document).ready(function () { 
415 
416        $('.dropdownContainer').on('click', '#deselect-all-button', function() { 
417            $('#column-selector').find(':checkbox').each(function() { 
418                if($(this).prop('checked') === true) { 
419                    this.click(); 
420
421            }); 
422        }) 
423 
424        $('.dropdownContainer').on('click', '#select-all-button', function() { 
425            $('#column-selector').find(':checkbox').each(function() { 
426                if($(this).prop('checked') === false) { 
427                    this.click(); 
428
429            }); 
430        })    
431 
432        $('#filter-container').on('click', '.filter-column', function() { 
433            var $currCheckboxGroup = $(this).closest('.checkbox-group'); 
434            var numCurrFieldSelectedCheckbox = $currCheckboxGroup.find('input.filter-column:checked').length; 
435            if(numCurrFieldSelectedCheckbox > 0){ 
436                $currCheckboxGroup.find('.clearFilter').removeClass('hidden'); 
437                $currCheckboxGroup.addClass('selected').find('.clearFilter').removeClass('hidden'); 
438            } else{ 
439                $currCheckboxGroup.find('.clearFilter').addClass('hidden'); 
440                $currCheckboxGroup.removeClass('selected').find('.clearFilter').addClass('hidden'); 
441
442            oTable.fnDraw(); 
443        }); 
444 
445        $('.dropdownContainer').on('click', '.clearFilter', function(e) { 
446            e.stopPropagation(); 
447            $(this).closest('.checkbox-group').find('input.filter-column').prop('checked', false); 
448            $(this).addClass('hidden'); 
449            $(this).closest('.checkbox-group').removeClass('selected'); 
450 
451            oTable.fnDraw(); 
452        }); 
453 
454        $.fn.dataTableExt.afnFiltering.push(function (oSettings, aData, iDataIndex) { 
455            var checked = {}; 
456            var inputs = $('.filter-column'); 
457 
458            for (var i = 0; i < inputs.length; i++) { 
459                var $input = $(inputs[i]); 
460                if ($input.is(':checked')) { 
461                    var index = $input.closest('.checkbox-group').data('column-index'); 
462                    var isDisplayed = $('#column-selector input[value='+ index +']').is(":checked"); 
463                    if (isDisplayed) { 
464                        if (!checked[index]) { 
465                            checked[index] = [$input.val()]; 
466                        } else { 
467                            checked[index].push($input.val()); 
468
469
470
471
472 
473            var keys = Object.keys(checked); 
474            var len = keys.length; 
475            var matches = []; 
476            if (len) { 
477                for (var i = 0; i < len; i++) { 
478                    var key = keys[i]; 
479                    var val = checked[key]; 
480 
481                    var raw = $(oTable.api().cell(iDataIndex, key).nodes()[0]).data('raw'); 
482                    if (typeof raw === "object") { 
483                        if (contains(raw, checked[key])) { 
484                            matches.push(true);  
485                        } else { 
486                            matches.push(false); 
487
488                    } else if (checked[key].indexOf(aData[key]) > -1) { 
489                        matches.push(true); 
490                    } else { 
491                        matches.push(false); 
492
493
494            } else { 
495                return true; 
496
497             
498            return matches.indexOf(false) == -1 ? true : false; 
499        }); 
500 
501        <#-- show/hide column and filtering for the column as well as update cookie when a column selector is selected/unselected --> 
502        $('#column-selector input').change(function(){ 
503            /** var columnFieldName = $(this).attr('data-field-name'); **/ 
504            var columnFieldName = $(this.parentElement).text().trim(); 
505            var columnIndex = parseInt($(this).val()); 
506            var column = oTable.api().column(columnIndex); 
507            var displayingColumnFieldNames = Cookies.getJSON(cookiePrefix + '${recordSet.getName(localeUtil.getDefault())}'); 
508 
509            if(!displayingColumnFieldNames) { 
510                displayingColumnFieldNames = []; 
511
512 
513            var cookieArrayIndex = displayingColumnFieldNames.indexOf(columnFieldName); 
514            if($(this).is(":checked")) { 
515                column.visible(true); 
516                $('.checkbox-group-column-'+(columnIndex)).show();  
517 
518                if(cookieArrayIndex == -1){ 
519                    displayingColumnFieldNames.push(columnFieldName); 
520
521            } else { 
522                column.visible(false); 
523                $('.checkbox-group-column-'+(columnIndex)).hide();  
524 
525                if(cookieArrayIndex != -1) { 
526                    displayingColumnFieldNames.splice(cookieArrayIndex, 1); 
527
528
529 
530            Cookies.set(cookiePrefix + '${recordSet.getName(localeUtil.getDefault())}', displayingColumnFieldNames, { expires: cookieExpireNumDays }); 
531 
532            oTable.fnDraw(); 
533        }); 
534 
535        if($('#productsInCat').length) { 
536            <#-- category page --> 
537            var cookiePrefix = 'SHARP_CATEGORY_FIELDS_'; 
538            var cookieExpireNumDays = 365; 
539            oTable = $('#productsInCat').dataTable({ 
540                "oLanguage": { 
541                   "sSearch": "Search for" 
542                 }, 
543                stateSave: true, 
544                "autoWidth": true, 
545                "dom": '<"top"Bf>rt<"bottom"ilp><"clear">', 
546                "scrollX": true, 
547                "info": true, 
548                "lengthMenu": [5, 10, 25, 50, 75, 100 ], 
549                "dom": 'Bfrtilp', 
550                buttons: [{ 
551                        text: 'Viewing Options', 
552                        extend: 'collection', 
553                        buttons: [ 
554
555                                text: 'Minimize Columns', 
556                                action: function(e, dt, node, config) { 
557                                    dt.responsive(); 
558                                    dt.responsive.recalc(); 
559                                    dt.columns.adjust().draw(); 
560
561                            }, 
562
563                                text: 'Show All Columns', 
564                                action: function(e, dt, node, config) { 
565                                    dt.responsive(); 
566                                    dt.responsive.rebuild(); 
567                                    dt.columns.adjust().draw(); 
568
569                            }, 
570                            'copy', 
571                            'excel', 
572                            'csv', 
573
574                                extend: 'pdfHtml5', 
575                                text: 'Landscape PDF', 
576                                pageOrientation: 'landscape', 
577                                pageSize: 'A0' 
578                            }, 
579
580                                extend: 'pdfHtml5', 
581                                text: 'Portrait PDF', 
582                                pageOrientation: 'portrait', 
583                                pageSize: 'A2' 
584                            }, 
585                            'print' 
586
587
588                ], 
589                initComplete: function() { 
590                    $('#productsInCat a.productNumber').each(function(){ 
591                        var productRecordId = $(this).attr('data-product-record-id'); 
592                        var currProductURL = addParameter('${currentURL}', 'sharpProductRecordId', productRecordId, false); 
593                        $(this).attr('href', currProductURL); 
594                    }); 
595
596            }); 
597             
598            $.fn.dataTableExt.afnFiltering.push( 
599                function( oSettings, aData, iDataIndex ) { 
600                    if ( aData[10] !== 'Discontinued' ) 
601
602                        return true; 
603
604                    return false; 
605
606            ); 
607             
608            var numColumn = oTable.fnSettings().aoColumns.length; 
609            var $rows = oTable.fnGetNodes(); 
610            var values = {}; 
611             
612            for(var col = 0; col < numColumn; col++){ 
613                var column = oTable.api().columns(col); 
614                var columnName = $(column.header()).attr('data-field-name'); 
615                 
616                if (columnName != '${productNumberFieldName}') { 
617                    if (typeof values[col] === "undefined") values[col] = {}; 
618                    var data = column.data()[0]; 
619 
620                    for (var row = 0; row < data.length; row++) { 
621                        var elem = $(oTable.api().cell(row, col).nodes()[0]).data('raw'); 
622                        if(elem === "[") { 
623                            elem = data[row]; 
624
625 
626                        if (elem != "" && typeof elem != "undefined") { 
627                            if (typeof elem === "object") { 
628                                try { 
629                                    for (var e = 0; e < elem.length; e++) { 
630                                        var element = elem[e]; 
631                                        if (typeof values[col][element] === 'undefined') { 
632                                            values[col][element] = 1; 
633                                        } else { 
634                                            values[col][element]++; 
635
636
637                                } catch (err) {  
638                                    console.log("Error: Parsing Invalid JSON: " + elem); 
639
640                            } else { 
641                                if (typeof values[col][elem] === 'undefined') { 
642                                    values[col][elem] = 1; 
643                                } else { 
644                                    values[col][elem]++; 
645
646
647 
648
649
650 
651                    var labels = []; 
652 
653                    for (var key in values[col]) { 
654                        var val = values[col][key]; 
655                        var $checkbox = $('<input/>', {'class': 'filter-column filter-column-' + col, 'type': 'checkbox', 'value': key}).data('colnum', col); 
656                        var $label = $('<label></label>', {'class': 'filter-container'}).append($checkbox).append(' ').append(key); 
657                         
658                        labels.push($label.get(0)); 
659
660                     
661                    var $columnFilterContainer = $('<div></div>', { 
662                        'class': 'checkbox-group checkbox-group-column-' + col, 
663                        'data-column-index' : col 
664                    }); 
665                     
666                    var $columnFilterLabel = $('<h4></h4>', { 
667                        'class': 'dropdownTrigger' 
668                    }).html($(oTable.api().columns(col).header()).text()); 
669                     
670                    var $columnFilterClear = $('<i></i>', { 
671                        'class': 'clearFilter hidden icon icon-remove-sign' 
672                    }); 
673 
674                    $columnFilterLabel.append($('<i></i>', {'class': 'icon-angle-down'})).append($columnFilterClear); 
675 
676                    var $sortedCheckboxes = $(labels).sort(function (a, b) { 
677                        return $(a).text().toLowerCase() > $(b).text().toLowerCase(); 
678                    }); 
679 
680                    var $sortedCheckboxesContainer = $('<div></div>', { 
681                        'class': 'dropdownContent' 
682                    }).append($sortedCheckboxes); 
683 
684                    $columnFilterContainer.append($columnFilterLabel).append($sortedCheckboxesContainer); 
685 
686                    $('#filter-container').append($columnFilterContainer); 
687
688
689 
690            <#-- get cookie and set the column selector --> 
691            var cookieFields = Cookies.getJSON(cookiePrefix + '${recordSet.getName(localeUtil.getDefault())}'); 
692            var headers = oTable.api().columns().header(); 
693 
694            if(cookieFields){ 
695                for (var i = 0; i < headers.length; i++) { 
696                    var header = $(headers[i]).text(); 
697                    if (cookieFields.indexOf(header) > -1) { 
698                        $('#column-selector input[value='+ i +']').prop('checked', true); 
699
700
701            } else { 
702                initDisplayFields = []; 
703                <#-- display all fields if no cookie found --> 
704 
705                for (var i = 0; i < headers.length; i++) { 
706                    var header = $(headers[i]).text(); 
707                    initDisplayFields.push(header); 
708                    $('#column-selector input[value='+ i +']').prop('checked', true); 
709
710 
711                Cookies.set(cookiePrefix + '${recordSet.getName(localeUtil.getDefault())}', initDisplayFields, { expires: cookieExpireNumDays }); 
712
713 
714            <#-- show/hide column and filtering for the column based on whether the column selector is checked or not. --> 
715            $('#column-selector input').each(function(){ 
716                var columnIndex = parseInt($(this).val()); 
717                var column = oTable.api().column(columnIndex); 
718                 
719                if($(this).is(":checked")){ 
720                    column.visible(true); 
721                    $('.checkbox-group-column-' + columnIndex).show(); 
722                } else{ 
723                    column.visible(false); 
724                    $('.checkbox-group-column-' + columnIndex).hide(); 
725
726            }); 
727 
728            /** Order the filters **/ 
729            var groups = $('.checkbox-group .dropdownContent'); 
730 
731            for (var i = 0; i < groups.size(); i++) { 
732                var group = groups[i]; 
733                var labels = $(group).find('label'); 
734 
735                labels.sort(function(a,b){ 
736                    var an = $(a).find('input').val(); 
737                    var bn = $(b).find('input').val(); 
738 
739                    if(an > bn) { 
740                        return 1; 
741
742                    if(an < bn) { 
743                        return -1; 
744
745                    return 0; 
746                }); 
747 
748                labels.detach().appendTo(group); 
749
750 
751            /** does not fix the issue with loading all columns **/ 
752             
753            oTable.fnAdjustColumnSizing(); 
754 
755            <#-- clone nav menu and place it below product technology --> 
756 
757            $( "#navigation .Products .child-menu" ).clone().appendTo( ".side-buttons .product-technology" ).removeClass("child-menu").addClass("technology-menu"); 
758 
759            var $arrows = $('<i></i>', { 
760                'class': 'icon icon-angle-down' 
761            }); 
762 
763            $arrows.appendTo($(".technology-menu .baby-menu").siblings("a")); 
764 
765            $(".product-technology a").click(function(e){ 
766                $(this).siblings(".technology-menu").slideToggle(200); 
767            }); 
768 
769            $(".product-technology .technology-menu > li").click(function(){ 
770                $(this).children(".baby-menu").slideToggle(200); 
771                $(this).toggleClass("open"); 
772                $(this).siblings("li").removeClass("open").children(".baby-menu").hide(200); 
773            }); 
774 
775            $('.product-technology .technology-menu .baby-menu li').click(function(e) { 
776               e.stopPropagation(); 
777            }); 
778 
779            <#-- hide dropdown content and toggle the content when its trigger is clicked --> 
780 
781            $('.dropdownContent').hide(); 
782            $('.dropdownContainer').on('click', '.dropdownTrigger', function(){ 
783                $( this ).toggleClass("open").siblings('.dropdownContent').slideToggle(); 
784            });  
785 
786            <#-- set href attribute linking to individual product page --> 
787            $('#productsInCat').on( 'draw.dt', function () { 
788                $('#productsInCat a.productNumber').each(function(){ 
789                    var productRecordId = $(this).attr('data-product-record-id'); 
790                    var currProductURL = addParameter('${currentURL}', 'sharpProductRecordId', productRecordId, false); 
791                    $(this).attr('href', currProductURL); 
792                }); 
793            }); 
794 
795            $('#productsInCat a.productNumber').click(function(e) { 
796               e.stopPropagation(); 
797            }); 
798 
799        } else { 
800            <#-- individual product page --> 
801            $('.prodDocumentation .tableWrap').show(); 
802 
803            $('.prodSpecifications, .prodDocumentation').on('click', 'thead tr', function(){ 
804                $( this ).closest('table').next('div .tableWrap').slideToggle(); 
805                $( this ).toggleClass("open"); 
806            }); 
807 
808            <#-- set href attribute linking to category page --> 
809            $('a.backToCategory').each(function(){ 
810                var currCategoryURL = removeParameter('${currentURL}', 'sharpProductRecordId'); 
811                $(this).attr('href', currCategoryURL); 
812            }); 
813 
814            <#-- set href attribute linking to where-to-buy page for individual product --> 
815            $('a.buyIndProductBtn').each(function(){ 
816                var currProductNumber = $(this).attr('data-product-number'); 
817                var currWhereToBuyURL = addParameter('/where-to-buy', 'keywords', currProductNumber, false); 
818                currWhereToBuyURL = addParameter(currWhereToBuyURL, "buyNow", "true", false); 
819                $(this).attr('href', currWhereToBuyURL); 
820            }); 
821
822    }); 
823     
824 
825    function addParameter(url, parameterName, parameterValue, atStart){ 
826        replaceDuplicates = true; 
827        if(url.indexOf('#') > 0){ 
828            var cl = url.indexOf('#'); 
829            urlhash = url.substring(url.indexOf('#'),url.length); 
830        } else { 
831            urlhash = ''; 
832             
833            cl = url.length; 
834
835        sourceUrl = url.substring(0,cl); 
836 
837        var urlParts = sourceUrl.split("?"); 
838        var newQueryString = ""; 
839 
840        if (urlParts.length > 1 && urlParts[1] != '') 
841
842            var parameters = urlParts[1].split("&"); 
843            for (var i=0; (i < parameters.length); i++) 
844
845                var parameterParts = parameters[i].split("="); 
846                if (!(replaceDuplicates && parameterParts[0] == parameterName)) 
847
848                    if (newQueryString == "") 
849                        newQueryString = "?"; 
850                    else 
851                        newQueryString += "&"; 
852                    newQueryString += parameterParts[0] + "=" + (parameterParts[1]?parameterParts[1]:''); 
853
854
855
856        if (newQueryString == "") 
857            newQueryString = "?"; 
858 
859        if(atStart){ 
860            newQueryString = '?'+ parameterName + "=" + parameterValue + (newQueryString.length>1?'&'+newQueryString.substring(1):''); 
861        } else { 
862            if (newQueryString !== "" && newQueryString != '?') 
863                newQueryString += "&"; 
864            newQueryString += parameterName + "=" + (parameterValue?parameterValue:''); 
865
866        return urlParts[0] + newQueryString + urlhash; 
867    }; 
868 
869 
870    function removeParameter(url, parameter) { 
871        <#-- prefer to use l.search if you have a location/link object --> 
872        var urlparts= url.split('?');    
873        if (urlparts.length>=2) { 
874 
875            var prefix= encodeURIComponent(parameter)+'='; 
876            var pars= urlparts[1].split(/[&;]/g); 
877 
878            <#-- reverse iteration as may be destructive --> 
879            for (var i= pars.length; i-- > 0;) {     
880                <#-- idiom for string.startsWith --> 
881                if (pars[i].lastIndexOf(prefix, 0) !== -1) {   
882                    pars.splice(i, 1); 
883
884
885 
886            url= urlparts[0]+'?'+pars.join('&'); 
887            return url; 
888        } else { 
889            return url; 
890
891
892 
893    function contains(a1, a2) { 
894      for (var i = 0; i < a2.length; i++) { 
895        if (a1.indexOf(a2[i]) === -1)  
896          return false; 
897
898      return true; 
899
900 
901</script> 

.