• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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: 19668
92
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: 19668
92
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!