Win a copy of Java by Comparison (eBook) this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Adding client id or class attribute for each th in the DataTable  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I 've tried a lot of ways to put a client id or css class in <th> tags, but i haven't succeeded what i did. In fact, i want to specify class or id for each <th>. Normally there is columnHeader property for but when i want to use it i am getting a "Attribute headerClass invalid for tag column according to TLD" error. <datatable headerClass> only allows a general description (for all <th>). When I use <h: outputText styleClass>, it writes into <span> . Is there another way to ensure this?

 
Bartender
Posts: 19183
85
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Mjora!

First I have to ask why you need to do this. If you're expecting to be taking action in the backing bean based on a cell's ID, you should be warned that it's A) ugly, B) difficult, C) unreliable and most importantly D) probably something you should be doing using a DataModel.

The id of your JSF elements in your View Template is not the same id that will appear in the generated HTML that renders from the template. The raw HTML has IDs that are synthesized from the ID of the element plus the IDs of its parent elements. That ID is not formed according to standardized rules, so it may vary depending on the version of JSF you are using, the webapp server/JSF implementation you are using, and may change unpredictably if you edit the View Template.

Any View element may have an id field, but whether generated HTML elements will or will not and what those IDs will be is less predictable. So be very certain before attempting to do anything with them.
 
Mjora Kolkhetishi
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly thanks for your reply. I understand, but i want to use dragtable.js plugin on DataTable because of change the order of columns and id (specially) or class properties are need for saving status.
 
Tim Holloway
Bartender
Posts: 19183
85
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem with dragtable.js is that it's designed to work on raw HTML. You're not working with raw HTML, you're working with JSF.

Making it even worse is that dragtable is a jQuery add-in, and it's common for JSF to have its own internal copy of jQuery which might be a conflicting version.

A much cleaner solution would be to use one of the smart extension JSF libraries such as PrimeFaces that has draggable table elements built into the JSF table tag itself.
 
Don't touch me. And dont' touch this tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!