Subject: | Behavior of jsAddData, Stray Debug Output and a Feture Request (Maybe) |
Date: | Tue, 6 Dec 2011 12:21:29 -0700 |
To: | <bug-html-editabletable [...] rt.cpan.org> |
From: | "Grey" <GreyNomad [...] comcast.net> |
Thanks for writing HTML-EditableTable. I am using it to replace a lot of my
own code that has become almost unmaintainable. I do have what I consider to
be a bug to report, and a feature request. I hope that you're still
maintaining the code.
The First Bug: I believe that the behavior of jsAddData is not consistent
with the documentation. The documentation says:
For Horizontal tables. Use to activate javascript to support addition of
new table rows.
$table->setJsAddData(1);
# indicates that a button to insert a row of data into the table is to be
provided when in edit mode
However, the code in Horizontal.pm does this:
if ($colSpec->{'formElement'} && ($colSpec->{'formElement'} eq
'deleteRowButton')) {
print "<th>" . "<input type=button value='add row'
onClick=\"addData()\">" . "</th>";
}
The 'add row' button is added not if jsAddData is set, but if a 'delete row'
button is reqested. There is, in fact, no reference to 'jsAddData' in the
code. I believe this code shoud read as follows:
if ($colSpec->{'formElement'} && ($colSpec->{'formElement'} eq
'deleteRowButton') && $self->{'jsAddData'}) {
print "<th>" . "<input type=button value='add row'
onClick=\"addData()\">" . "</th>";
}
I had to put 'label' => ' ' in the column definition to avoid a 'label
missing' message in the header, but that was trivial.
Why does this concern me? Because I want my table to be editable so that I
get the 'remove' buttons, but I don't want the fields on the display to be
editable. The horizontal table displays the more important (summary) fields
for the row entity, but to edit the row the user clicks on the key field and
gets a horizontal display to edit all the fields in the record. And I need
to provide my own 'add row' button to bring up an 'empty' form to add a new
record.
The problem with my implementation is that it works for me, but it will
break existing code that people may have written. I'll leave that up to you
to figure out.
So now I have an 'add row' button above my table, which looks klunky. A nice
enhancement would be to provide the option to supply the link for the 'add
row' function, so that if I set jsAddData, I could also supply my own link.
Something like 'headerCallback' => \&myRoutine. The regular 'callback'
option doesn't get called for headers, and I'm already using it to replace
the JavaScript 'remove' button with my own link to my function to display
the row and confirm the delete request.
Okay, enough of that. Bug the Second:
When the 'htmlDisplay' is called, I was getting 'debug displayCount = 0'
displayed on the page. in the Javascript.pm module I found this at line 70:
print "debug displayCount = $javascriptDisplayCount<br>";
I commented the line out. It obviously doesn't belong in the released code.
The Feature Request: It would be nice to be able to specify some table
parameters like cell padding and alignment. I suppose I can do that with
CSS, but I haven't had time to play with that yet. If you don't hear back
from me on that, you can assume that I've got it working without any
problems.
Regards,
~~ Grey