Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
per column css classes (colgroups?)
01/09/2009
08:23
Avatar
pbor
Member
Members
Forum Posts: 33
Member Since:
01/09/2009
sp_UserOfflineSmall Offline

Hi, I'd like to have some per-column css classes to customize the look of some columns (in particular the first and last column, but there are also other usecases)

Would it be possible to make jqgrid emit <colgroup> tags and let the user specify css classes on it?

I gave it a try and came up with something like this patch, but I am not sure if it is the best way to do it...

diff --git a/js/grid.base.js b/js/grid.base.js
index 5074e7c..95ed716 100644
--- a/js/grid.base.js
+++ b/js/grid.base.js
@@ -1036,6 +1036,11 @@ $.fn.jqGrid = function( p ) {
if(ts.p.scroll===true){
ts.p.pgbuttons = false; ts.p.pginput=false; ts.p.rowList=[];
}
+ for(i=0;i<this.p.colNames.length;i++){
+ var cgc = ts.p.colModel[i].name;
+ var colgrp = "<colgroup span='1' class='ui-column "+cgc+"'/>";

+ $(this).append(colgrp);
+ }
var thead = "<thead><tr class='ui-jqgrid-labels' role='rowheader'>",
tdc, idn, w, res, sort,
td, ptr, tbody, imgs,iac="",idc="";

then you can specify the colclass css class in the colmodel:

    colModel:[
        {name:'id',index:'id',xmlmap:"id",colclass:"first",resizable:false},
        {name:'owner',index:'owner',xmlmap:"owner",resizable:false},
        {name:'status',index:'status',xmlmap:"status",resizable:false},
        {name:'name', index:'name',xmlmap:"name",colclass:"last",resizable:false}
    ],

01/09/2009
08:37
Avatar
pbor
Member
Members
Forum Posts: 33
Member Since:
01/09/2009
sp_UserOfflineSmall Offline

Sorry, I am not very used to forums, so I made some errors in the above post and I ended up cut and pasting the wrong version of the patch instead of the one of the version I am testing... some notes:

1) in the patch var cgc = ts.p.colModel[i].name should be ts.p.colModel[i].colclass

2) I added a ui-column class to each column... this was more of a test, not sure it is useful

3) It is probably good to always add special css classes to the first and last column, since they are useful to customize css borders

04/09/2009
06:00
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Thanks for this.

To be a honest setting colgroup is a little bit difficult. The problem is not that I can not do this. The problem is that colgroup have diffrent behaviours on diffrent browsers (espacially in FireFox, Safari and Chrome).

Best Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

04/09/2009
10:31
Avatar
pbor
Member
Members
Forum Posts: 33
Member Since:
01/09/2009
sp_UserOfflineSmall Offline

Hi, thanks for the reply.

I admit I am no cross-browser expert, but colgroup seemed to work ok for just setting the style without fancy stuff like spanning multiple columns etc.

That said I am not particularly attached to colgroups, what I really need is the ability to set style for specific columns, and in particular for the first and the last. Would you consider adding that, even in a different way like setting the class on every cell?

08/09/2009
07:43
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Just to know - I have try to add this feature, but as usuall all IE browsers make me not happy.

Best Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
52 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information