Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Jtable uneditable cells in a specific table column (regardless of row)

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
scenario:

4 columns and lots of rows

column 1 and 2 cells are editable
while column 3 and 4 cells are not editable.

is this possible? if so, any help would be appreciated ^^

btw, i also tried overriding the isCellEditable(int row,int column) but the output is all cells in every column are not editable,
i only need the column 3 and 4 to be uneditable while the others are still editable.
 
Rancher
Posts: 3262
30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

btw, i also tried overriding the isCellEditable(int row,int column) but the output is all cells in every column are not editable,



Then you code is wrong. You need to add an "if statement" to control which columns are editable and which ones are not.
 
Sheriff
Posts: 6914
1314
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"borj bn", please check your private messages regarding an important administrative matter.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> i also tried overriding the isCellEditable(int row,int column) but the output is all cells in every column are not editable,

in isCellEditable(int row,int column), you only need to
return column < 2;//0-based
 
borj bersas
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is my code,


still all of the cells are affected, can anyone of you guys reconstruct my code? tnx in advance
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just by creating another 'mainTable', from the original's model,
doesn't do anything to the original 'mainTable', which is presumably
the one showing on the screen, and therefore all editable

search this forum (or google) isCellEditable and you'll find numerous examples
that you can compile/run and test to see that they do work, then modify your code accordingly
 
Devaka Cooray
Sheriff
Posts: 6914
1314
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
borj, please UseCodeTags. I've added code tags for you.
 
borj bersas
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oops! sorry admin hehe,
btw, i solved my problem hehe, tnx for your effort guys

 
Whose rules are you playing by? This tiny ad doesn't respect those rules:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic