PDA

View Full Version : ColumnModel - access to ygrid-col-n rules


Animal
11-10-2006, 07:36 AM
Would it be possible to add a function to the DefaultColumnModel which gives access to the style object for that column's ygrid-col-n style?

That way, you could delegate special formatting to the ColumnModel - which is what has the knowledge of what columns should look like.

Currently, the ColumnModel doesn't know anything about the Grid, so it doesn't know the id, so it can't do


var rule = YAHOO.ext.util.CSS.getRule(["#" + this.grid.id + " .ygrid-row", ".ygrid-row"]);
rule.textAlign = "center";


Which is what I want on certain columns.

The DataModel might want a say in this too. I know this might break MVC separation, but is there a way round that?

My current problem, is that some Grids need an extra column of checkboxes, so that multiple columns can be selected (They don't want normal selection by just highlighting the row, they want checkboxes!). So I tell my Grid object which tells its ColumnModel (which adds an extra column), and the DataModel, which inserts an extra Boolean data value. This column needs to be centred to look right.

jack.slocum
11-10-2006, 08:41 AM
That's a tough one. I can add it to the GridView, but the column model isn't tied to the grid so there's no real way to do it.

Does you grid object have access to the grid? You could just have it call updateRule directly?

Animal
11-10-2006, 09:05 AM
Yes, that's what I'm doing. My AspicioGrid has a config option { checkboxes:true } which, if true, it creates its explicit rule for col-0 with text-align:center.

But overall, I think public access to the column rules is a good idea. GridView would be the place to offer it.

jack.slocum
11-10-2006, 09:24 AM
There's no reason setCCSWidth, can't be "setColumnStyle" or something and take a style param. I added it to the list.