Custom Table Data for table component cq5.5 | Community
Skip to main content
October 16, 2015
Solved

Custom Table Data for table component cq5.5

  • October 16, 2015
  • 3 replies
  • 1346 views

Hello, 

I have a table component I have made that I want to include code at the beginning, but also be editable. For table data I have the following code 

<button onclick="cecontrol('row') ">–/+</buton>

<table border=" 0" cellspacing="0" cellpadding="1" width="100%" id="row">

I can put that in, and it works until it is edited. Once it is edited the first line is deleted and the id="row" is deleted. Is there a way to code it so that is always included in that component? 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by PaulMcMahon

A simple hack would be to extend the table component, add your button in the JSP, and then parse the HTML from the text property and add your id value to the table tag. It's a hack but it would work. 

The complicated version would be to look at overriding the Ext JS Table Plugin for the Rich Text Editor widget and change its behavior so it either ignores your code, or adds it in automatically for you. I don't have examples of that for you, but you can take a look at http://dev.day.com/docs/en/cq/current/developing/widgets.html#par_title_3 for information on rich text plugins generally. 

3 replies

PaulMcMahonAccepted solution
Level 8
October 16, 2015

A simple hack would be to extend the table component, add your button in the JSP, and then parse the HTML from the text property and add your id value to the table tag. It's a hack but it would work. 

The complicated version would be to look at overriding the Ext JS Table Plugin for the Rich Text Editor widget and change its behavior so it either ignores your code, or adds it in automatically for you. I don't have examples of that for you, but you can take a look at http://dev.day.com/docs/en/cq/current/developing/widgets.html#par_title_3 for information on rich text plugins generally. 

October 16, 2015

Thanks for your quick response, 

The problem with the first solution is that anytime the table is edited, it generates the default table border, cellspacing, cellpadding line of code and ignores the id="row" because of this. The button does stay, but it no longer functions. 

Level 8
October 16, 2015

That's why you have to parse the text in the JSP when the component renders - you don't edit the row attribute in the content, you parse the content and add everytime your JSP renders - that's how you get around the behavior of the widget.