[ 16 posts ] Go to page 1, 2 Next

Luk Gastmans

  • Username: lgastmans
  • Joined: Tue May 05, 2009 9:46 pm
  • Posts: 12
  • IRC: Luk
  • Offline
  • Profile
Tags:

hidden columns in datatable

Post Posted: Tue May 05, 2009 10:26 pm
+0-
Hi All,

I have an issue with columns in the yui datatable that are hidden - as you can see in the screenshot. For some reason, hidden columns still take up minimal width, and if there are multiple hidden columns, these create a grey vertical band as seen in the screenshot attached.

The reason there are hidden columns is that the user can select which fields are visible or not....

Grateful for any suggestions :)

Jenny Donnelly

YUI Developer

  • Username: jenny
  • Joined: Tue Dec 09, 2008 5:00 pm
  • Posts: 58
  • GitHub: jenny
  • Gists: jenny
  • YUI Developer
  • Offline
  • Profile
Tags:

Re: hidden columns in datatable

Post Posted: Wed May 06, 2009 9:52 am
+0-
It sounds like you are looking for removeColumn() rather than hideColumn().

Cheers,
Jenny

Luk Gastmans

  • Username: lgastmans
  • Joined: Tue May 05, 2009 9:46 pm
  • Posts: 12
  • IRC: Luk
  • Offline
  • Profile

Re: hidden columns in datatable

Post Posted: Wed May 06, 2009 8:22 pm
+0-
I generate the array for the myColumnDefs with a php file that reads a table for the properties of the columns to display. Below I pasted the array returned, in which some of the columns are set to "hidden":true.

var myColumnDefs = [{"key":"product_id","formatter":"number","parser":"number","label":"product_id","width":100,"hidden":true,"sortable":true,"isPrimaryKey":true,"alias":"sp","fieldname":"product_id"},{"key":"product_code","formatter":"string","parser":"string","label":"code","width":80,"hidden":false,"sortable":true,"isPrimaryKey":false,"alias":"sp","fieldname":"product_code"},{"key":"product_bar_code","formatter":"string","parser":"string","label":"barcode","width":300,"hidden":false,"sortable":true,"isPrimaryKey":false,"alias":"sp","fieldname":"product_bar_code"},{"key":"product_description","formatter":"string","parser":"string","label":"description","width":100,"hidden":false,"sortable":true,"isPrimaryKey":false,"alias":"sp","fieldname":"product_description"},{"key":"category_description","formatter":"string","parser":"string","label":"category","width":100,"hidden":false,"sortable":true,"isPrimaryKey":false,"alias":"sc","fieldname":"category_description"},{"key":"mrp","formatter":"number","parser":"number","label":"mrp","width":100,"hidden":false,"sortable":true,"isPrimaryKey":false,"alias":"sp","fieldname":"mrp"},{"key":"is_available","formatter":"boolean","parser":"boolean","label":"is_available","width":100,"hidden":true,"sortable":true,"isPrimaryKey":false,"alias":"sp","fieldname":"is_available"},{"key":"is_av_product","formatter":"boolean","parser":"boolean","label":"is_av_product","width":100,"hidden":true,"sortable":true,"isPrimaryKey":false,"alias":"sp","fieldname":"is_av_product"},{"key":"is_perishable","formatter":"boolean","parser":"boolean","label":"is_perishable","width":100,"hidden":true,"sortable":true,"isPrimaryKey":false,"alias":"sp","fieldname":"is_perishable"},{"key":"list_in_purchase","formatter":"boolean","parser":"boolean","label":"list_in_purchase","width":100,"hidden":true,"sortable":true,"isPrimaryKey":false,"alias":"sp","fieldname":"list_in_purchase"},{"key":"minimum_qty","formatter":"number","parser":"number","label":"minimum_qty","width":100,"hidden":true,"sortable":true,"isPrimaryKey":false,"alias":"sp","fieldname":"minimum_qty"},{"key":"tax_description","formatter":"string","parser":"string","label":"tax_description","width":100,"hidden":false,"sortable":true,"isPrimaryKey":false,"alias":"st","fieldname":"tax_description"},{"key":"measurement_unit","formatter":"string","parser":"string","label":"measurement_unit","width":100,"hidden":false,"sortable":true,"isPrimaryKey":false,"alias":"mu","fieldname":"measurement_unit"},{"key":"supplier_name","formatter":"string","parser":"string","label":"supplier_name","width":100,"hidden":false,"sortable":true,"isPrimaryKey":false,"alias":"ss","fieldname":"supplier_name"},{"key":"image_filename","formatter":"formatImage","parser":"string","label":"image_filename","width":100,"hidden":false,"sortable":true,"isPrimaryKey":false,"alias":"sp","fieldname":"image_filename"}];
myColumnDefs.push({key:"delete", label:' ', className:'delete-button', action:'delete'});

You mean I should run the removeColumn after this?

Thanks for your time!!

Luk Gastmans

  • Username: lgastmans
  • Joined: Tue May 05, 2009 9:46 pm
  • Posts: 12
  • IRC: Luk
  • Offline
  • Profile
Tags:

Re: hidden columns in datatable

Post Posted: Wed May 06, 2009 8:59 pm
+0-
Dear Jenny,

I thought maybe it would be clearer if I showed you how I set this array:

Code:
var myColumnDefs = <? get_grid_fields($grid_name, $user_id); ?>;


:)

Jenny Donnelly

YUI Developer

  • Username: jenny
  • Joined: Tue Dec 09, 2008 5:00 pm
  • Posts: 58
  • GitHub: jenny
  • Gists: jenny
  • YUI Developer
  • Offline
  • Profile
Tags:

Re: hidden columns in datatable

Post Posted: Thu May 07, 2009 8:16 am
+0-
In order to not display a given Column, simply omit its definition from your myColumnDefs array. You can call insertColumn() later if you do want to display it.

Luk Gastmans

  • Username: lgastmans
  • Joined: Tue May 05, 2009 9:46 pm
  • Posts: 12
  • IRC: Luk
  • Offline
  • Profile
Tags:

Re: hidden columns in datatable

Post Posted: Thu May 07, 2009 7:30 pm
+0-
yes, of course... :?

Except for the first column in the definitions that I showed, as that is the primary key and required for further actions, like deletion or editing, but which I do not want to display in the grid. So the only way for this column is to include it in the list and set its hidden property to false, right?

thanks, again, for your time

Luke Smith

YUI Contributor

  • Username: lsmith
  • Joined: Thu Aug 28, 2008 7:50 am
  • Posts: 511
  • Location: Sunnyvale
  • Twitter: ls_n
  • GitHub: lsmith
  • Gists: lsmith
  • IRC: ls_n
  • YUI Developer
  • Offline
  • Profile

Re: hidden columns in datatable

Post Posted: Thu May 07, 2009 8:10 pm
+0-
Omitting columns from the DataTable's column definition is not the same as excluding fields from the DataSource's fields collection. Have a look at this example. Hopefully it will be helpful.

http://yuiblog.com/sandbox/yui/v270/exa ... _cols.html

razer21

  • Joined: Wed May 13, 2009 10:25 am
  • Posts: 2
  • Offline
  • Profile

Re: hidden columns in datatable

Post Posted: Wed May 13, 2009 10:27 am
+0-
it is a css problem that causes this. only the div element inside the table cell is hidden actually not the table cell itself. I have written a work around for exactly this problem, please go read http://normankosmal.com/wordpress/?p=45

Luk Gastmans

  • Username: lgastmans
  • Joined: Tue May 05, 2009 9:46 pm
  • Posts: 12
  • IRC: Luk
  • Offline
  • Profile
Tags:

Re: hidden columns in datatable

Post Posted: Thu May 14, 2009 7:59 pm
+0-
Thanks Norman, that worked perfectly for me!

With Gratitude

Luk

Luk Gastmans

  • Username: lgastmans
  • Joined: Tue May 05, 2009 9:46 pm
  • Posts: 12
  • IRC: Luk
  • Offline
  • Profile

Re: hidden columns in datatable

Post Posted: Fri Jun 05, 2009 4:55 am
+0-
just for those interested: this bug apparently appears in Firefox but not in IE, so in case you are applying this css fix, you should apply it only for Firefox
  [ 16 posts ] Go to page 1, 2 Next
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum